Package pal.io
Class FormattedInput
java.lang.Object
pal.io.FormattedInput
- All Implemented Interfaces:
Serializable
tools to simplify formatted input from an input stream
- Version:
- $Id: FormattedInput.java,v 1.7 2002/10/14 06:54:25 matt Exp $
- Author:
- Korbinian Strimmer
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic FormattedInput
create new instance of this object (note that there is no public constructor because this class is a singleton!)void
go to the beginning of the next line.double
read next number from stream and convert it to a double (newline/cr are treated as separators)double
readDouble
(PushbackReader in, boolean ignoreNewlineCR) read next number from stream and convert it to a doubleint
read next number from stream and convert it to a int (newline/cr are treated as separators)int
readInt
(PushbackReader in, boolean ignoreNewlineCR) read next number from stream and convert it to a intreadLabel
(PushbackReader in, int maxLength) read sequence label from stream A sequence label is not allowed to contain whitespace and either of :,;()[]{}.readLine
(PushbackReader in, boolean keepWhiteSpace) read a whole lineint
readNextChar
(PushbackReader input) read next character from stream (EOF does not count as character but will throw exception)readNumber
(PushbackReader in, boolean ignoreNewlineCR) read word from streamint
go to first non-whitespace character
-
Method Details
-
getInstance
create new instance of this object (note that there is no public constructor because this class is a singleton!) -
nextLine
go to the beginning of the next line. Recognized line terminators: Unix: \n, DOS: \r\n, Macintosh: \r- Parameters:
in
- input stream- Throws:
IOException
-
readLine
read a whole line- Parameters:
in
- input streamkeepWhiteSpace
- keep or drop white space- Returns:
- string with content of line
- Throws:
IOException
-
skipWhiteSpace
go to first non-whitespace character- Parameters:
in
- input stream- Returns:
- character or EOF
- Throws:
IOException
-
readNextChar
read next character from stream (EOF does not count as character but will throw exception)- Parameters:
input
- input stream- Returns:
- character
- Throws:
IOException
-
readWord
read word from stream- Parameters:
input
- stream- Returns:
- word read from stream
- Throws:
IOException
-
readLabel
read sequence label from stream A sequence label is not allowed to contain whitespace and either of :,;()[]{}. Note that newline/cr is NOT counted as white space!!- Parameters:
in
- input streammaxLength
- maximum allowed length of label (if negative any length is permitted)- Returns:
- label
- Throws:
IOException
-
readNumber
- Throws:
IOException
-
readDouble
read next number from stream and convert it to a double (newline/cr are treated as separators)- Parameters:
in
- input stream- Returns:
- double
- Throws:
IOException
NumberFormatException
-
readDouble
public double readDouble(PushbackReader in, boolean ignoreNewlineCR) throws IOException, NumberFormatException read next number from stream and convert it to a double- Parameters:
in
- input streamignoreNewlineCR
- ignore newline/cr as separator- Returns:
- double
- Throws:
IOException
NumberFormatException
-
readInt
read next number from stream and convert it to a int (newline/cr are treated as separators)- Parameters:
in
- input stream- Returns:
- integer
- Throws:
IOException
NumberFormatException
-
readInt
public int readInt(PushbackReader in, boolean ignoreNewlineCR) throws IOException, NumberFormatException read next number from stream and convert it to a int- Parameters:
in
- input streamignoreNewlineCR
- ignore newline/cr as separator- Returns:
- integer
- Throws:
IOException
NumberFormatException
-