Package uk.ac.gda.util.io
Class TokenFileParser
java.lang.Object
uk.ac.gda.util.io.TokenFileParser
Read a tabbed delimited file into columns. Each row must have
the same number of entries currently.
Assumes that files are small. For larger files use StreamTokenizer(Reader r) which is more efficient.
-
Constructor Summary
ConstructorsConstructorDescriptionTokenFileParser(File file) TokenFileParser(InputStream unbuffered) NOTE Does not use StreamTokenizer so files need to be small.TokenFileParser(URL url) -
Method Summary
Modifier and TypeMethodDescriptiongetColumn(int icol) Double[]getColumnAsDoubleArray(int i, int... ignoreRows) Exceptions can be thrown if the column cannot parse as doublegetColumnAsDoubleList(int i, int... ignoreRows) getToken()voidparse()Must be called to parse the file.voidsetCommentChar(String commentChar) voidtoString()
-
Constructor Details
-
TokenFileParser
- Parameters:
url-- Throws:
IOException
-
TokenFileParser
- Parameters:
file-- Throws:
IOException
-
TokenFileParser
NOTE Does not use StreamTokenizer so files need to be small.- Parameters:
unbuffered-- Throws:
IOException
-
-
Method Details
-
parse
Must be called to parse the file.- Throws:
IOException
-
getColumn
- Parameters:
icol-- Returns:
- the exact column, modifying it will change the data
-
toString
-
getColumnAsDoubleArray
Exceptions can be thrown if the column cannot parse as double- Parameters:
i-- Returns:
- Double[]
-
getColumnAsDoubleList
- Parameters:
i-ignoreRows-- Returns:
- column as list of Doubles
-
getToken
-
setToken
-
getCommentChar
-
setCommentChar
-