Package com.sun.javatest.util
Class LineParser
- java.lang.Object
-
- com.sun.javatest.util.LineParser
-
public class LineParser extends java.lang.Object
A class to parse lines of words in a stream. Words may be unquoted sequences of non-blank characters, or may be quoted strings. Comments can be introduced by '#' and extend to the next newline character. Lines may be terminated by newline, semicolon or a comment.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LineParser.Fault
This exception is used to report problems while using a line parser.
-
Constructor Summary
Constructors Constructor Description LineParser(java.io.File file)
Create a line parser, reading the data in a given file.LineParser(java.io.Reader in)
Create a line parser, reading data from an anonymous stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.File
getFile()
Get the file being read, or null if it is not available.int
getLineNumber()
Get the current line number within the stream being read.java.lang.String[]
readLine()
Read the next line of words from the input stream.
-
-
-
Constructor Detail
-
LineParser
public LineParser(java.io.File file) throws java.io.FileNotFoundException, java.io.IOException
Create a line parser, reading the data in a given file.- Parameters:
file
- the file to be read- Throws:
java.io.FileNotFoundException
- if the file was not foundjava.io.IOException
- if there is some problem opening the file or reading the initial characters of the file
-
LineParser
public LineParser(java.io.Reader in)
Create a line parser, reading data from an anonymous stream.- Parameters:
in
- the stream from which to read the data
-
-
Method Detail
-
getFile
public java.io.File getFile()
Get the file being read, or null if it is not available.- Returns:
- the file being read, or null if not available
-
getLineNumber
public int getLineNumber()
Get the current line number within the stream being read.- Returns:
- the current line number within nthe stream being read
-
readLine
public java.lang.String[] readLine() throws LineParser.Fault
Read the next line of words from the input stream.- Returns:
- the next line of words from the input stream
- Throws:
LineParser.Fault
- if there is a problem reading the required data -- such as an unterminated string
-
-