|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.restlet.util.ByteUtils
public final class ByteUtils
Byte manipulation utilities.
| Method Summary | |
|---|---|
static long |
exhaust(InputStream input)
Exhauts the content of the representation by reading it and silently discarding anything read. |
static ReadableByteChannel |
getChannel(InputStream inputStream)
Returns a readable byte channel based on a given inputstream. |
static WritableByteChannel |
getChannel(OutputStream outputStream)
Returns a writable byte channel based on a given output stream. |
static ReadableByteChannel |
getChannel(Representation representation)
Returns a readable byte channel based on the given representation's content and its write(WritableByteChannel) method. |
static Reader |
getReader(InputStream stream,
CharacterSet characterSet)
Returns a reader from an input stream and a character set. |
static Reader |
getReader(WriterRepresentation representation)
Returns a reader from a writer representation.Internally, it uses a writer thread and a pipe stream. |
static InputStream |
getStream(ReadableByteChannel readableChannel)
Returns an input stream based on a given readable byte channel. |
static InputStream |
getStream(Reader reader,
CharacterSet characterSet)
Returns an input stream based on a given character reader. |
static InputStream |
getStream(Representation representation)
Returns an input stream based on the given representation's content and its write(OutputStream) method. |
static OutputStream |
getStream(WritableByteChannel writableChannel)
Returns an output stream based on a given writable byte channel. |
static OutputStream |
getStream(Writer writer)
Returns an output stream based on a given writer. |
static String |
toString(InputStream inputStream)
Converts an input stream to a string. As this method uses the InputstreamReader class, the default character set is used for decoding the input stream. |
static String |
toString(InputStream inputStream,
CharacterSet characterSet)
Converts an input stream to a string using the specified character set for decoding the input stream. |
static String |
toString(Reader reader)
Converts a reader to a string. |
static void |
write(FileChannel fileChannel,
WritableByteChannel writableChannel)
Writes the representation to a byte channel. |
static void |
write(InputStream inputStream,
OutputStream outputStream)
Writes an input stream to an output stream. |
static void |
write(InputStream inputStream,
RandomAccessFile randomAccessFile)
Writes an input stream to a random access file. |
static void |
write(ReadableByteChannel readableChannel,
WritableByteChannel writableChannel)
Writes a readable channel to a writable channel. |
static void |
write(Reader reader,
Writer writer)
Writes characters from a reader to a writer. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static long exhaust(InputStream input)
throws IOException
input - The input stream to exhaust.
IOExceptionpublic static ReadableByteChannel getChannel(InputStream inputStream)
inputStream - The input stream to convert.
public static WritableByteChannel getChannel(OutputStream outputStream)
outputStream - The output stream.
public static ReadableByteChannel getChannel(Representation representation)
throws IOException
representation - the representation to get the OutputStream from.
IOException
public static Reader getReader(InputStream stream,
CharacterSet characterSet)
throws UnsupportedEncodingException
stream - The input stream.characterSet - The character set. May be null.
UnsupportedEncodingException - if a character set is given, but not supported
public static Reader getReader(WriterRepresentation representation)
throws IOException
representation - The representation to read from.
IOExceptionpublic static InputStream getStream(ReadableByteChannel readableChannel)
readableChannel - The readable byte channel.
public static InputStream getStream(Reader reader,
CharacterSet characterSet)
reader - The character reader.characterSet - The stream character set.
public static InputStream getStream(Representation representation)
representation - the representation to get the OutputStream from.
public static OutputStream getStream(WritableByteChannel writableChannel)
writableChannel - The writable byte channel.
public static OutputStream getStream(Writer writer)
writer - The writer.
public static String toString(InputStream inputStream)
inputStream - The input stream.
toString(InputStream, CharacterSet)
public static String toString(InputStream inputStream,
CharacterSet characterSet)
inputStream - The input stream.characterSet - The character set
public static String toString(Reader reader)
reader - The characters reader.
public static void write(FileChannel fileChannel,
WritableByteChannel writableChannel)
throws IOException
fileChannel - The readable file channel.writableChannel - A writable byte channel.
IOException
public static void write(InputStream inputStream,
OutputStream outputStream)
throws IOException
inputStream - The input stream.outputStream - The output stream.
IOException
public static void write(InputStream inputStream,
RandomAccessFile randomAccessFile)
throws IOException
inputStream - The input stream.randomAccessFile - The random access file.
IOException
public static void write(ReadableByteChannel readableChannel,
WritableByteChannel writableChannel)
throws IOException
readableChannel - The readable channel.writableChannel - The writable channel.
IOException
public static void write(Reader reader,
Writer writer)
throws IOException
reader - The reader.writer - The writer.
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||