com.foxsmart.ic.io
Class SimpleStreamReader

java.lang.Object
  extended by com.foxsmart.ic.io.SimpleStreamReader

public class SimpleStreamReader
extends java.lang.Object

This class provides the ability to read the entire contents of a stream into a returned byte array. For more granular control of streams with a known size, use StreamReader.


Constructor Summary
SimpleStreamReader(java.io.File file)
          Constructs a stream reader from a File.
SimpleStreamReader(java.io.InputStream inputStream)
          Constructs a stream reader from an Input Stream.
SimpleStreamReader(java.net.URL url)
          Constructs a stream reader from a URL.
 
Method Summary
 byte[] read()
          Read all bytes from the input stream and return them in a byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleStreamReader

public SimpleStreamReader(java.net.URL url)
                   throws java.io.IOException
Constructs a stream reader from a URL.

Parameters:
url - The URL to create the stream from
Throws:
java.io.IOException - if the URL stream could not be opened to the URL
java.net.UnknownServiceException - if the URL protocol does not support input

SimpleStreamReader

public SimpleStreamReader(java.io.File file)
                   throws java.io.IOException
Constructs a stream reader from a File.

Parameters:
file - The file to create the stream from
Throws:
java.net.MalformedURLException - if the path cannot be parsed as a URL.
java.io.IOException - if the URL stream could not be opened to the URL
java.net.UnknownServiceException - if the URL protocol does not support input

SimpleStreamReader

public SimpleStreamReader(java.io.InputStream inputStream)
Constructs a stream reader from an Input Stream.

Parameters:
inputStream - The Input Stream to read from.
Method Detail

read

public byte[] read()
            throws java.io.IOException
Read all bytes from the input stream and return them in a byte array. The input stream will be closed once all the bytes have been read.

Returns:
The full stream contents.
Throws:
java.io.IOException - if the stream could not be read or an error occurred while reading from the stream.


Copyright © 2005-2008 Fox Smart, Inc. All Rights Reserved.