opennlp.tools.util
Class PlainTextByLineStream

java.lang.Object
  extended by opennlp.tools.util.PlainTextByLineStream
All Implemented Interfaces:
ObjectStream<String>

public class PlainTextByLineStream
extends Object
implements ObjectStream<String>

Reads a plain text file and return each line as a String object.


Constructor Summary
PlainTextByLineStream(FileChannel channel, Charset encoding)
           
PlainTextByLineStream(FileChannel channel, String charsetName)
           
PlainTextByLineStream(InputStream in, Charset charset)
           
PlainTextByLineStream(InputStream in, String charsetName)
           
PlainTextByLineStream(Reader in)
          Initializes the current instance.
 
Method Summary
 void close()
          Closes the ObjectStream and releases all allocated resources.
 String read()
          Returns the next object.
 void reset()
          Repositions the stream at the beginning and the previously seen object sequence will be repeated exactly.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PlainTextByLineStream

public PlainTextByLineStream(Reader in)
Initializes the current instance.

Parameters:
in -

PlainTextByLineStream

public PlainTextByLineStream(InputStream in,
                             String charsetName)
                      throws UnsupportedEncodingException
Throws:
UnsupportedEncodingException

PlainTextByLineStream

public PlainTextByLineStream(InputStream in,
                             Charset charset)

PlainTextByLineStream

public PlainTextByLineStream(FileChannel channel,
                             String charsetName)

PlainTextByLineStream

public PlainTextByLineStream(FileChannel channel,
                             Charset encoding)
Method Detail

read

public String read()
            throws IOException
Description copied from interface: ObjectStream
Returns the next object. Calling this method repeatedly until it returns null will return each object from the underlying source exactly once.

Specified by:
read in interface ObjectStream<String>
Returns:
the next object or null to signal that the stream is exhausted
Throws:
IOException

reset

public void reset()
           throws IOException
Description copied from interface: ObjectStream
Repositions the stream at the beginning and the previously seen object sequence will be repeated exactly. This method can be used to re-read the stream if multiple passes over the objects are required. The implementation of this method is optional.

Specified by:
reset in interface ObjectStream<String>
Throws:
IOException

close

public void close()
           throws IOException
Description copied from interface: ObjectStream
Closes the ObjectStream and releases all allocated resources. After close was called its not allowed to call read or reset.

Specified by:
close in interface ObjectStream<String>
Throws:
IOException


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.