Package pal.io
Class FormattedInput
- java.lang.Object
-
- pal.io.FormattedInput
-
- All Implemented Interfaces:
java.io.Serializable
public class FormattedInput extends java.lang.Object implements java.io.Serializabletools 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:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static FormattedInputgetInstance()create new instance of this object (note that there is no public constructor because this class is a singleton!)voidnextLine(java.io.PushbackReader in)go to the beginning of the next line.doublereadDouble(java.io.PushbackReader in)read next number from stream and convert it to a double (newline/cr are treated as separators)doublereadDouble(java.io.PushbackReader in, boolean ignoreNewlineCR)read next number from stream and convert it to a doubleintreadInt(java.io.PushbackReader in)read next number from stream and convert it to a int (newline/cr are treated as separators)intreadInt(java.io.PushbackReader in, boolean ignoreNewlineCR)read next number from stream and convert it to a intjava.lang.StringreadLabel(java.io.PushbackReader in, int maxLength)read sequence label from stream A sequence label is not allowed to contain whitespace and either of :,;()[]{}.java.lang.StringreadLine(java.io.PushbackReader in, boolean keepWhiteSpace)read a whole lineintreadNextChar(java.io.PushbackReader input)read next character from stream (EOF does not count as character but will throw exception)java.lang.StringreadNumber(java.io.PushbackReader in, boolean ignoreNewlineCR)java.lang.StringreadWord(java.io.PushbackReader in)read word from streamintskipWhiteSpace(java.io.PushbackReader in)go to first non-whitespace character
-
-
-
Method Detail
-
getInstance
public static FormattedInput getInstance()
create new instance of this object (note that there is no public constructor because this class is a singleton!)
-
nextLine
public void nextLine(java.io.PushbackReader in) throws java.io.IOExceptiongo to the beginning of the next line. Recognized line terminators: Unix: \n, DOS: \r\n, Macintosh: \r- Parameters:
in- input stream- Throws:
java.io.IOException
-
readLine
public java.lang.String readLine(java.io.PushbackReader in, boolean keepWhiteSpace) throws java.io.IOExceptionread a whole line- Parameters:
in- input streamkeepWhiteSpace- keep or drop white space- Returns:
- string with content of line
- Throws:
java.io.IOException
-
skipWhiteSpace
public int skipWhiteSpace(java.io.PushbackReader in) throws java.io.IOExceptiongo to first non-whitespace character- Parameters:
in- input stream- Returns:
- character or EOF
- Throws:
java.io.IOException
-
readNextChar
public int readNextChar(java.io.PushbackReader input) throws java.io.IOExceptionread next character from stream (EOF does not count as character but will throw exception)- Parameters:
input- input stream- Returns:
- character
- Throws:
java.io.IOException
-
readWord
public java.lang.String readWord(java.io.PushbackReader in) throws java.io.IOExceptionread word from stream- Parameters:
input- stream- Returns:
- word read from stream
- Throws:
java.io.IOException
-
readLabel
public java.lang.String readLabel(java.io.PushbackReader in, int maxLength) throws java.io.IOExceptionread 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:
java.io.IOException
-
readNumber
public java.lang.String readNumber(java.io.PushbackReader in, boolean ignoreNewlineCR) throws java.io.IOException- Throws:
java.io.IOException
-
readDouble
public double readDouble(java.io.PushbackReader in) throws java.io.IOException, java.lang.NumberFormatExceptionread next number from stream and convert it to a double (newline/cr are treated as separators)- Parameters:
in- input stream- Returns:
- double
- Throws:
java.io.IOExceptionjava.lang.NumberFormatException
-
readDouble
public double readDouble(java.io.PushbackReader in, boolean ignoreNewlineCR) throws java.io.IOException, java.lang.NumberFormatExceptionread next number from stream and convert it to a double- Parameters:
in- input streamignoreNewlineCR- ignore newline/cr as separator- Returns:
- double
- Throws:
java.io.IOExceptionjava.lang.NumberFormatException
-
readInt
public int readInt(java.io.PushbackReader in) throws java.io.IOException, java.lang.NumberFormatExceptionread next number from stream and convert it to a int (newline/cr are treated as separators)- Parameters:
in- input stream- Returns:
- integer
- Throws:
java.io.IOExceptionjava.lang.NumberFormatException
-
readInt
public int readInt(java.io.PushbackReader in, boolean ignoreNewlineCR) throws java.io.IOException, java.lang.NumberFormatExceptionread next number from stream and convert it to a int- Parameters:
in- input streamignoreNewlineCR- ignore newline/cr as separator- Returns:
- integer
- Throws:
java.io.IOExceptionjava.lang.NumberFormatException
-
-