ImageScience 3.0.0

imagescience.utility
Class LineReader

java.lang.Object
  extended by imagescience.utility.LineReader

public class LineReader
extends java.lang.Object

Reads text line-by-line from a character stream using buffering for efficiency. Inspired by java.io.BufferedReader but with methods providing information about how many characters were actually read during the last call and how many lines were read in total.


Constructor Summary
LineReader(java.io.Reader reader)
          Constructs a buffered line reader from the given character stream reader.
 
Method Summary
 long chars()
          Returns the number of characters read using this reader.
 void close()
          Closes the character stream reader and releases any system resources associated with it.
 long lines()
          Returns the number of lines read using this reader.
 java.lang.String read()
          Reads a line of text.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LineReader

public LineReader(java.io.Reader reader)
Constructs a buffered line reader from the given character stream reader.

Parameters:
reader - The character stream reader.
Method Detail

read

public java.lang.String read()
                      throws java.io.IOException
Reads a line of text. A line is considered to be terminated by any of a line feed, a carriage return, or a carriage return followed immediately by a line feed.

Returns:
A String containing the contents of the line, not including any line-termination characters, or null if the end of the stream has been reached.
Throws:
java.io.IOException - If an I/O error occurs.

chars

public long chars()
Returns the number of characters read using this reader.

Returns:
The number of characters read using this reader.

lines

public long lines()
Returns the number of lines read using this reader.

Returns:
The number of lines read using this reader.

close

public void close()
           throws java.io.IOException
Closes the character stream reader and releases any system resources associated with it.

Throws:
java.io.IOException - If an I/O error occurs.

ImageScience 3.0.0

Copyright (C) Erik Meijering. Permission to use this software and corresponding documentation for educational, research, and not-for-profit purposes, without a fee and without a signed licensing agreement, is granted, subject to the following terms and conditions.

IT IS NOT ALLOWED TO REDISTRIBUTE, SELL, OR LEASE THIS SOFTWARE, OR DERIVATIVE WORKS THEREOF, WITHOUT PERMISSION IN WRITING FROM THE COPYRIGHT HOLDER. THE COPYRIGHT HOLDER IS FREE TO MAKE VERSIONS OF THE SOFTWARE AVAILABLE FOR A FEE OR COMMERCIALLY ONLY.

IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OF ANY KIND WHATSOEVER, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.

THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE EXPRESS OR IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE AND CORRESPONDING DOCUMENTATION IS PROVIDED "AS IS". THE COPYRIGHT HOLDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.