All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class sdsu.io.ChunkReader

java.lang.Object
   |
   +----sdsu.io.ChunkReader

public class ChunkReader
extends Object
implements Enumeration
A chunk is any sequence of characters you wish. A chunk could be a single line, a table, or a complete document. The ChunkWriter separates chunks with a string separator, called a chunk seperator. The separator can be any string. The separator is not part of a chunk. The separator should be selected to insure that it does not occur in the input as a part of a chunk, as it will be interpreted as the end of the chunk not as part of the chunk. ChunkWriter will return each chunk one at a time.

Version:
0.8 7 January 1998
Author:
Roger Whitney (whitney@cs.sdsu.edu)

Constructor Index

 o ChunkReader(Reader, String)
Create a ChunkReader object with a Reader as an input and the given separator.
 o ChunkReader(String, String)
Create a ChunkReader object with a String as an input and the given separator.

Method Index

 o eof()
Returns true if there are more blocks of data in the input.
 o fromFile(String, String)
Create a ChunkReader object with a file as an input and the given separator.
 o hasMoreElements()
Returns true if there are more blocks of data in the input.
 o nextElement()
Returns the next block of data.
 o readChunk()
Returns the next block of data.
 o setSeparator(String)

Constructors

 o ChunkReader
 public ChunkReader(Reader in,
                    String separator)
Create a ChunkReader object with a Reader as an input and the given separator. This class does not buffer the reader for you.

 o ChunkReader
 public ChunkReader(String input,
                    String separator)
Create a ChunkReader object with a String as an input and the given separator.

Methods

 o fromFile
 public static ChunkReader fromFile(String fileName,
                                    String separator) throws FileNotFoundException
Create a ChunkReader object with a file as an input and the given separator. File IO will be buffered for you.

Throws: FileNotFoundException
thrown if fileName is not valid file name.
 o setSeparator
 public void setSeparator(String newSeparator)
 o eof
 public boolean eof()
Returns true if there are more blocks of data in the input.

 o hasMoreElements
 public boolean hasMoreElements()
Returns true if there are more blocks of data in the input.

 o readChunk
 public Object readChunk()
Returns the next block of data.

Throws: NoSuchElementException
if there are no blocks of data left.
 o nextElement
 public Object nextElement()
Returns the next block of data.

Throws: NoSuchElementException
if there are no blocks of data left.

All Packages  Class Hierarchy  This Package  Previous  Next  Index