net.sourceforge.groboutils.util.io.v1
Class ReadStringStream

java.lang.Object
  extended bynet.sourceforge.groboutils.util.io.v1.ReadStringStream

public class ReadStringStream
extends java.lang.Object

Reads a byte array from a stream until the stream is finished. You can specify a maximum size to read, and the block read size.

Since:
Alpha 0.9.1d (sometime in 2001)
Version:
$Date: 2003/02/10 22:52:45 $
Author:
Matt Albrecht groboclown@users.sourceforge.net

Field Summary
static int DEFAULT_BLOCK_READ_SIZE
          Default block read size.
static int READ_TO_END_OF_STREAM
          Read in an unlimited number of bytes.
 
Constructor Summary
ReadStringStream(java.io.Reader input)
          Create a new stream using the default parameters and the given reader.
ReadStringStream(java.io.Reader input, int maxReadSize, int blockReadSize)
           
 
Method Summary
 java.lang.String readStringStream()
          Read in the byte stream, using the current settings.
static java.lang.String readStringStream(java.io.Reader input)
          Read in the byte stream.
static java.lang.String readStringStream(java.io.Reader input, int maxReadSize, int blockReadSize)
          Read in the stream to a String.
 void setReader(java.io.Reader input)
          Sets the internal input stream.
 void setSizes(int maxReadSize, int blockReadSize)
          Sets the internal sizes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

READ_TO_END_OF_STREAM

public static final int READ_TO_END_OF_STREAM
Read in an unlimited number of bytes. This can be very dangerous.

See Also:
Constant Field Values

DEFAULT_BLOCK_READ_SIZE

public static final int DEFAULT_BLOCK_READ_SIZE
Default block read size.

See Also:
Constant Field Values
Constructor Detail

ReadStringStream

public ReadStringStream(java.io.Reader input)
Create a new stream using the default parameters and the given reader.

Parameters:
input - reader to pull from.

ReadStringStream

public ReadStringStream(java.io.Reader input,
                        int maxReadSize,
                        int blockReadSize)
Parameters:
input - reader to pull from.
Method Detail

setReader

public void setReader(java.io.Reader input)
Sets the internal input stream.

Parameters:
input - reader to pull from.

setSizes

public void setSizes(int maxReadSize,
                     int blockReadSize)
Sets the internal sizes.


readStringStream

public java.lang.String readStringStream()
                                  throws java.io.IOException
Read in the byte stream, using the current settings.

Returns:
the read-in string
Throws:
java.io.IOException

readStringStream

public static java.lang.String readStringStream(java.io.Reader input)
                                         throws java.io.IOException
Read in the byte stream. Does not close the stream after it has finished reading. Uses the default sizes.

Parameters:
input - reader to pull from.
Returns:
the read-in string
Throws:
java.io.IOException
See Also:
readStringStream( Reader, int, int )

readStringStream

public static java.lang.String readStringStream(java.io.Reader input,
                                                int maxReadSize,
                                                int blockReadSize)
                                         throws java.io.IOException
Read in the stream to a String. Does not close the stream after it has finished reading.

Note that there is no variable checking, for performance reasons. The user needs to verify that:

Parameters:
input - the reader, which cannot be null.
maxReadSize - the maximum number of bytes to read, which must be positive, and must be modulo 0 of blockReadSize. This is an "estimation", and may actually read in more than this many bytes if it is not modulo 0 of blockReadSize, but will always return all the bytes read.
blockReadSize - the number of bytes to read in per read command, which cannot be more than maxReadSize, and cannot be less than or equal to zero.
Throws:
java.io.IOException


Copyright © 2001-2003 by The GroboUtils Project