|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectutil.AsciiReader
public class AsciiReader
A class providing static methods for reading ASCII-files. Used to spare
comment lines, marked with a starting COMMENT char, from input.
| Nested Class Summary | |
|---|---|
static class |
AsciiReader.BlockData
Reads a block file and prints the desired columns to standard out. |
static class |
AsciiReader.BlockReformat
Similar to block data, this class reads an ascii-column file, but on output performs a re-format using the decimal formatters specified. |
static class |
AsciiReader.InsertColumn
Reads a block file and adds a column to the data. |
static class |
AsciiReader.PixelMatch
Reads two files with 2D points given at the appropriate indices and matches them for the desired precision. |
static class |
AsciiReader.Time
Converts lines in hh:mm:ss.sss to ms. |
| Field Summary | |
|---|---|
static char[] |
COMMENT
A char array with comment-line markers. |
private static String |
STRCOM
The string representation of the COMMENT array for ease. |
| Constructor Summary | |
|---|---|
AsciiReader()
|
|
| Method Summary | ||
|---|---|---|
static List<List<String>> |
extractTokens(List<String> lines,
List<Integer> cols)
Extract only the requested columns as string tokens in the requested order. |
|
static Map<Integer,List<Double>> |
getDoubleColumns(List<String> lines,
Collection<Integer> columns)
Takes a list of valid lines and extracts double values out of it. |
|
static List<String> |
getLines(File file)
Converts the filename into a file from which the names are read in. |
|
static List<String> |
getLines(File listfile,
boolean trim)
Retrieves a list of strings from a file. |
|
static List<String> |
getLines(InputStream in)
Reads from an input stream with trimming enabled. |
|
static List<String> |
getLines(InputStream instream,
boolean trim)
Reads from an input stream. |
|
static List<String> |
getLines(String filename)
Converts the filename into a file from which the names are read in. |
|
static List<String> |
getLines(String path,
String filename)
Converts the filename into a file from which the names are read in. |
|
static List<String> |
getLines(URL resource)
Retrieves a list of strings from a URL. |
|
static List<String> |
getLines(URL resource,
boolean trim)
Retrieves a list of strings from a URL. |
|
static
|
getNumberColumns(List<String> lines,
Map<Integer,Class<T>> columns)
Extract valid lines to numbers of the given types. |
|
static List<Double> |
getSingleColumn(List<String> lines,
int c)
Returns a list of doubles from the stated colum. |
|
static Map<Integer,List<String>> |
getTokenColumns(List<String> lines,
Collection<Integer> cols)
Extract columns to strings. |
|
static Map<Integer,List<Number>> |
parseNumberColumns(List<String> lines,
Map<Integer,? extends NumberFormat> format)
Extract valid lines to numbers of the given types. |
|
static VectorG[] |
parseVector(List<String> lines,
Collection<Integer> columns)
Parses a list of lines into an array of VectorGs. |
|
static VectorG[] |
parseVector(List<String> lines,
Map<Integer,? extends NumberFormat> format)
Parses a list of lines into an array of VectorGs. |
|
private static
|
vectorParsing(Collection<Integer> columns,
Map<Integer,List<T>> col2vals)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final char[] COMMENT
private static final String STRCOM
COMMENT array for ease.
| Constructor Detail |
|---|
public AsciiReader()
| Method Detail |
|---|
public static List<String> getLines(String path,
String filename)
FileAccess.fromName(java.lang.String, java.lang.String)public static List<String> getLines(String filename)
FileAccess.fromName(java.lang.String, java.lang.String)public static List<String> getLines(File file)
FileAccess.fromName(java.lang.String, java.lang.String)
public static List<String> getLines(File listfile,
boolean trim)
COMMENT are ignored.
If the target file cannot be found or read, null is returned.
If the target list file is empty or consists of only comment lines
an empty list is returned.
listfile - An ASCII-file with comments.trim - True if lines should be trimmed.
public static List<String> getLines(URL resource)
COMMENT are ignored.
If the target cannot be found or opened, null is returned.
If the target list is empty or consists of only comment lines
an empty list is returned.
resource - An URL pointing to an ASCII-file.
public static List<String> getLines(URL resource,
boolean trim)
COMMENT are ignored.
If the target cannot be found or opened, null is returned.
If the target list is empty or consists of only comment lines
an empty list is returned.
resource - An URL pointing to an ASCII-file.trim - True if lines should be trimmed.
public static List<String> getLines(InputStream in)
public static List<String> getLines(InputStream instream,
boolean trim)
public static List<Double> getSingleColumn(List<String> lines,
int c)
public static Map<Integer,List<Double>> getDoubleColumns(List<String> lines,
Collection<Integer> columns)
public static VectorG[] parseVector(List<String> lines,
Map<Integer,? extends NumberFormat> format)
public static VectorG[] parseVector(List<String> lines,
Collection<Integer> columns)
private static <T extends Number> VectorG[] vectorParsing(Collection<Integer> columns,
Map<Integer,List<T>> col2vals)
public static Map<Integer,List<String>> getTokenColumns(List<String> lines,
Collection<Integer> cols)
public static List<List<String>> extractTokens(List<String> lines,
List<Integer> cols)
public static Map<Integer,List<Number>> parseNumberColumns(List<String> lines,
Map<Integer,? extends NumberFormat> format)
throws ParseException
ParseException
public static <T extends Number> Map<Integer,List<T>> getNumberColumns(List<String> lines,
Map<Integer,Class<T>> columns)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||