org.restlet.client.engine.io
Class IoUtils

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

public class IoUtils
extends Object

IO manipulation utilities.

Author:
Thierry Boileau

Field Summary
static int BUFFER_SIZE
          The size to use when instantiating buffered items such as instances of the BufferedReader class.
static int TIMEOUT_MS
          The number of milliseconds after which IO operation will time out.
 
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
 

Field Detail

BUFFER_SIZE

public static final int BUFFER_SIZE
The size to use when instantiating buffered items such as instances of the BufferedReader class. It looks for the System property "org.restlet.client.engine.io.bufferSize" and if not defined, uses the "8192" default value.


TIMEOUT_MS

public static final int TIMEOUT_MS
The number of milliseconds after which IO operation will time out. It looks for the System property "org.restlet.client.engine.io.timeoutMs" and if not defined, uses the "60000" default value.

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, 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

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


Copyright © 2005-2014 Restlet.