Package org.apache.james.mime4j.util
Class ContentUtil
- java.lang.Object
-
- org.apache.james.mime4j.util.ContentUtil
-
public class ContentUtil extends Object
Utility methods for converting textual content of a message.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]buffer(InputStream in)static Stringbuffer(Reader in)static voidcopy(InputStream in, OutputStream out)Copies the contents of one stream to the other.static voidcopy(Reader in, Writer out)Copies the contents of one stream to the other.static Stringdecode(Charset charset, ByteSequence byteSequence)Decodes the specified sequence of bytes into a string using the specified charset.static Stringdecode(Charset charset, ByteSequence byteSequence, int offset, int length)Decodes a sub-sequence of the specified sequence of bytes into a string using the specified charset.static Stringdecode(ByteSequence byteSequence)Decodes the specified sequence of bytes into a string using the US-ASCII charset.static Stringdecode(ByteSequence byteSequence, int offset, int length)Decodes a sub-sequence of the specified sequence of bytes into a string using the US-ASCII charset.static ByteSequenceencode(CharSequence string)Encodes the specified string into an immutable sequence of bytes using the US-ASCII charset.static ByteSequenceencode(Charset charset, CharSequence string)Encodes the specified string into an immutable sequence of bytes using the specified charset.static byte[]toAsciiByteArray(String s)static StringtoAsciiString(byte[] b)static StringtoAsciiString(byte[] b, int off, int len)static StringtoAsciiString(ByteArrayBuffer b)static byte[]toByteArray(String s, Charset charset)static StringtoString(byte[] b, int off, int len, Charset charset)static StringtoString(byte[] b, Charset charset)static StringtoString(ByteArrayBuffer b, Charset charset)
-
-
-
Method Detail
-
copy
public static void copy(InputStream in, OutputStream out) throws IOException
Copies the contents of one stream to the other.- Parameters:
in- not nullout- not null- Throws:
IOException
-
copy
public static void copy(Reader in, Writer out) throws IOException
Copies the contents of one stream to the other.- Parameters:
in- not nullout- not null- Throws:
IOException
-
buffer
public static byte[] buffer(InputStream in) throws IOException
- Throws:
IOException
-
buffer
public static String buffer(Reader in) throws IOException
- Throws:
IOException
-
encode
public static ByteSequence encode(CharSequence string)
Encodes the specified string into an immutable sequence of bytes using the US-ASCII charset.- Parameters:
string- string to encode.- Returns:
- encoded string as an immutable sequence of bytes.
-
encode
public static ByteSequence encode(Charset charset, CharSequence string)
Encodes the specified string into an immutable sequence of bytes using the specified charset.- Parameters:
charset- Java charset to be used for the conversion.string- string to encode.- Returns:
- encoded string as an immutable sequence of bytes.
-
decode
public static String decode(ByteSequence byteSequence)
Decodes the specified sequence of bytes into a string using the US-ASCII charset.- Parameters:
byteSequence- sequence of bytes to decode.- Returns:
- decoded string.
-
decode
public static String decode(Charset charset, ByteSequence byteSequence)
Decodes the specified sequence of bytes into a string using the specified charset.- Parameters:
charset- Java charset to be used for the conversion.byteSequence- sequence of bytes to decode.- Returns:
- decoded string.
-
decode
public static String decode(ByteSequence byteSequence, int offset, int length)
Decodes a sub-sequence of the specified sequence of bytes into a string using the US-ASCII charset.- Parameters:
byteSequence- sequence of bytes to decode.offset- offset into the byte sequence.length- number of bytes.- Returns:
- decoded string.
-
decode
public static String decode(Charset charset, ByteSequence byteSequence, int offset, int length)
Decodes a sub-sequence of the specified sequence of bytes into a string using the specified charset.- Parameters:
charset- Java charset to be used for the conversion.byteSequence- sequence of bytes to decode.offset- offset into the byte sequence.length- number of bytes.- Returns:
- decoded string.
-
toAsciiByteArray
public static byte[] toAsciiByteArray(String s)
-
toAsciiString
public static String toAsciiString(byte[] b)
-
toAsciiString
public static String toAsciiString(byte[] b, int off, int len)
-
toString
public static String toString(ByteArrayBuffer b, Charset charset)
-
toAsciiString
public static String toAsciiString(ByteArrayBuffer b)
-
-