|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.restlet.engine.io.BioUtils
public final class BioUtils
Basic IO manipulation utilities.
Method Summary | |
---|---|
static void |
copy(java.io.InputStream inputStream,
java.io.OutputStream outputStream)
Copies an input stream to an output stream. |
static void |
copy(java.io.InputStream inputStream,
java.io.RandomAccessFile randomAccessFile)
Copies an input stream to a random access file. |
static void |
copy(java.io.Reader reader,
java.io.Writer writer)
Copies characters from a reader to a writer. |
static boolean |
delete(java.io.File file)
Deletes an individual file or an empty directory. |
static boolean |
delete(java.io.File file,
boolean recursive)
Deletes an individual file or a directory. |
static boolean |
delete(java.io.File file,
boolean recursive,
boolean garbageCollect)
Deletes an individual file or a directory. |
static long |
exhaust(java.io.InputStream input)
Exhaust the content of the representation by reading it and silently discarding anything read. |
static long |
getAvailableSize(Representation representation)
Returns the size effectively available. |
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.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.io.Writer writer)
Returns an output stream based on a given writer. |
static java.lang.String |
getText(Representation representation)
Converts the representation to a string value. |
static byte[] |
toByteArray(char[] chars)
Converts a char array into a byte array using the default character set. |
static byte[] |
toByteArray(char[] chars,
java.lang.String charsetName)
Converts a char array into a byte array using the default character set. |
static char[] |
toCharArray(byte[] bytes)
Converts a byte array into a character array using the default character set. |
static char[] |
toCharArray(byte[] bytes,
java.lang.String charsetName)
Converts a byte array into a character array using the default character set. |
static java.lang.String |
toHexString(byte[] byteArray)
Converts a byte array into an hexadecimal string. |
static java.lang.String |
toString(java.io.InputStream inputStream)
Converts an input stream to a string. |
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void copy(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 copy(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 copy(java.io.Reader reader, java.io.Writer writer) throws java.io.IOException
reader
- The reader.writer
- The writer.
java.io.IOException
public static boolean delete(java.io.File file)
file
- The individual file or directory to delete.
public static boolean delete(java.io.File file, boolean recursive)
file
- The individual file or directory to delete.recursive
- Indicates if directory with content should be deleted
recursively as well.
public static boolean delete(java.io.File file, boolean recursive, boolean garbageCollect)
file
- The individual file or directory to delete.recursive
- Indicates if directory with content should be deleted
recursively as well.garbageCollect
- Indicates if the garbage collector should be run.
public static long exhaust(java.io.InputStream input) throws java.io.IOException
input
- The input stream to exhaust.
java.io.IOException
public static long getAvailableSize(Representation representation)
Representation.getSize()
if no range is defined, otherwise it
returns the size of the range using Range.getSize()
.
representation
- The representation to evaluate.
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.OutputStream getStream(java.io.Writer writer)
writer
- The writer.
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.lang.String getText(Representation representation) throws java.io.IOException
representation
- The representation to convert.
java.io.IOException
public static byte[] toByteArray(char[] chars)
chars
- The source characters.
public static byte[] toByteArray(char[] chars, java.lang.String charsetName)
chars
- The source characters.charsetName
- The character set to use.
public static char[] toCharArray(byte[] bytes)
bytes
- The source bytes.
public static char[] toCharArray(byte[] bytes, java.lang.String charsetName)
bytes
- The source bytes.charsetName
- The character set to use.
public static java.lang.String toHexString(byte[] byteArray)
byteArray
- The byte array to convert.
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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |