org.restlet.client.engine.io
Class BioUtils

java.lang.Object
  extended by org.restlet.client.engine.io.BioUtils

public final class BioUtils
extends Object

Basic IO manipulation utilities.

Author:
Jerome Louvel

Method Summary
static long getAvailableSize(Representation representation)
          Returns the size effectively available.
static Reader getReader(InputStream stream, CharacterSet characterSet)
          Returns a reader from an input stream and a character set.
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getAvailableSize

public static long getAvailableSize(Representation representation)
Returns the size effectively available. This returns the same value as Representation.getSize() if no range is defined, otherwise it returns the size of the range using Range.getSize().

Parameters:
representation - The representation to evaluate.
Returns:
The available size.

getReader

public static Reader getReader(InputStream stream,
                               CharacterSet characterSet)
                        throws UnsupportedEncodingException
Returns a reader from an input stream and a character set.

Parameters:
stream - The input stream.
characterSet - The character set. May be null.
Returns:
The equivalent reader.
Throws:
UnsupportedEncodingException - if a character set is given, but not supported

toString

public 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.

Parameters:
inputStream - The input stream.
Returns:
The converted string.
See Also:
InputStreamReader class, toString(InputStream, CharacterSet)

toString

public static String toString(InputStream inputStream,
                              CharacterSet characterSet)
Converts an input stream to a string using the specified character set for decoding the input stream. Once read, the input stream is closed.

Parameters:
inputStream - The input stream.
characterSet - The character set
Returns:
The converted string.
See Also:
InputStreamReader class

toString

public static String toString(Reader reader)
Converts a reader to a string.

Parameters:
reader - The characters reader.
Returns:
The converted string.
See Also:
InputStreamReader class


Copyright © 2005-2012 Restlet S.A.S..