|
||||||||||
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(java.io.InputStream input)
Exhauts the content of the representation by reading it and silently discarding anything read. |
static java.nio.channels.ReadableByteChannel |
getChannel(java.io.InputStream inputStream)
Returns a readable byte channel based on a given inputstream. |
static java.nio.channels.WritableByteChannel |
getChannel(java.io.OutputStream outputStream)
Returns a writable byte channel based on a given output stream. |
static java.nio.channels.ReadableByteChannel |
getChannel(Representation representation)
Returns a readable byte channel based on the given representation's content and its write(WritableByteChannel) method. |
static java.io.Reader |
getReader(java.io.InputStream stream,
CharacterSet characterSet)
Returns a reader from an input stream and a character set. |
static java.io.Reader |
getReader(WriterRepresentation representation)
Returns a reader from a writer representation.Internally, it uses a writer thread and a pipe stream. |
static java.io.InputStream |
getStream(java.nio.channels.ReadableByteChannel readableChannel)
Returns an input stream based on a given readable byte channel. |
static java.io.InputStream |
getStream(java.io.Reader reader,
CharacterSet characterSet)
Returns an input stream based on a given character reader. |
static java.io.InputStream |
getStream(Representation representation)
Returns an input stream based on the given representation's content and its write(OutputStream) method. |
static java.io.OutputStream |
getStream(java.nio.channels.WritableByteChannel writableChannel)
Returns an output stream based on a given writable byte channel. |
static java.io.OutputStream |
getStream(java.io.Writer writer)
Returns an output stream based on a given writer. |
static java.lang.String |
toString(java.io.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 java.lang.String |
toString(java.io.InputStream inputStream,
CharacterSet characterSet)
Converts an input stream to a string using the specified character set for decoding the input stream. |
static java.lang.String |
toString(java.io.Reader reader)
Converts a reader to a string. |
static void |
write(java.nio.channels.FileChannel fileChannel,
java.nio.channels.WritableByteChannel writableChannel)
Writes the representation to a byte channel. |
static void |
write(java.io.InputStream inputStream,
java.io.OutputStream outputStream)
Writes an input stream to an output stream. |
static void |
write(java.io.InputStream inputStream,
java.io.RandomAccessFile randomAccessFile)
Writes an input stream to a random access file. |
static void |
write(java.nio.channels.ReadableByteChannel readableChannel,
java.nio.channels.WritableByteChannel writableChannel)
Writes a readable channel to a writable channel. |
static void |
write(java.io.Reader reader,
java.io.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(java.io.InputStream input) throws java.io.IOException
input
- The input stream to exhaust.
java.io.IOException
public static java.nio.channels.ReadableByteChannel getChannel(java.io.InputStream inputStream)
inputStream
- The input stream to convert.
public static java.nio.channels.WritableByteChannel getChannel(java.io.OutputStream outputStream)
outputStream
- The output stream.
public static java.nio.channels.ReadableByteChannel getChannel(Representation representation) throws java.io.IOException
representation
- the representation to get the OutputStream
from.
java.io.IOException
public static java.io.Reader getReader(java.io.InputStream stream, CharacterSet characterSet) throws java.io.UnsupportedEncodingException
stream
- The input stream.characterSet
- The character set. May be null.
java.io.UnsupportedEncodingException
- if a character set is given, but not supportedpublic static java.io.Reader getReader(WriterRepresentation representation) throws java.io.IOException
representation
- The representation to read from.
java.io.IOException
public static java.io.InputStream getStream(java.nio.channels.ReadableByteChannel readableChannel)
readableChannel
- The readable byte channel.
public static java.io.InputStream getStream(java.io.Reader reader, CharacterSet characterSet)
reader
- The character reader.characterSet
- The stream character set.
public static java.io.InputStream getStream(Representation representation)
representation
- the representation to get the OutputStream
from.
public static java.io.OutputStream getStream(java.nio.channels.WritableByteChannel writableChannel)
writableChannel
- The writable byte channel.
public static java.io.OutputStream getStream(java.io.Writer writer)
writer
- The writer.
public static java.lang.String toString(java.io.InputStream inputStream)
inputStream
- The input stream.
toString(InputStream, CharacterSet)
public static java.lang.String toString(java.io.InputStream inputStream, CharacterSet characterSet)
inputStream
- The input stream.characterSet
- The character set
public static java.lang.String toString(java.io.Reader reader)
reader
- The characters reader.
public static void write(java.nio.channels.FileChannel fileChannel, java.nio.channels.WritableByteChannel writableChannel) throws java.io.IOException
fileChannel
- The readable file channel.writableChannel
- A writable byte channel.
java.io.IOException
public static void write(java.io.InputStream inputStream, java.io.OutputStream outputStream) throws java.io.IOException
inputStream
- The input stream.outputStream
- The output stream.
java.io.IOException
public static void write(java.io.InputStream inputStream, java.io.RandomAccessFile randomAccessFile) throws java.io.IOException
inputStream
- The input stream.randomAccessFile
- The random access file.
java.io.IOException
public static void write(java.nio.channels.ReadableByteChannel readableChannel, java.nio.channels.WritableByteChannel writableChannel) throws java.io.IOException
readableChannel
- The readable channel.writableChannel
- The writable channel.
java.io.IOException
public static void write(java.io.Reader reader, java.io.Writer writer) throws java.io.IOException
reader
- The reader.writer
- The writer.
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |