com.darwinsys.csv
Class CSVRE
java.lang.Object
com.darwinsys.csv.CSVRE
- All Implemented Interfaces:
- CSVParser
public class CSVRE
- extends java.lang.Object
- implements CSVParser
Simple demo of CSV matching using Regular Expressions.
Does NOT use the "CSV" class defined in the Java CookBook, but uses
a regex pattern simplified from Chapter 7 of Mastering Regular
Expressions (p. 205, first edn.)
Example usage:
public static void main(String[] argv) throws IOException {
System.out.println(CSV_PATTERN);
new CSVRE().process(new BufferedReader(new InputStreamReader(System.in)));
}
- Version:
- $Id: CSVRE.java,v 1.23 2007/01/18 15:32:28 ian Exp $
Field Summary |
static java.lang.String |
CSV_PATTERN
The rather involved pattern used to match CSV's consists of three
alternations: the first matches a quoted field, the second unquoted,
the third a null field. |
Constructor Summary |
CSVRE()
|
Method Summary |
static void |
main(java.lang.String[] argv)
|
java.util.List<java.lang.String> |
parse(java.lang.String line)
Parse one line. |
void |
process(java.io.BufferedReader input)
Process one file. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CSV_PATTERN
public static final java.lang.String CSV_PATTERN
- The rather involved pattern used to match CSV's consists of three
alternations: the first matches a quoted field, the second unquoted,
the third a null field.
- See Also:
- Constant Field Values
CSVRE
public CSVRE()
main
public static void main(java.lang.String[] argv)
throws java.io.IOException
- Throws:
java.io.IOException
process
public void process(java.io.BufferedReader input)
throws java.io.IOException
- Process one file. Delegates to parse() a line at a time
- Throws:
java.io.IOException
parse
public java.util.List<java.lang.String> parse(java.lang.String line)
- Parse one line.
- Specified by:
parse
in interface CSVParser
- Returns:
- List of Strings, minus their double quotes
Copyright © 1996-2004 Ian F. Darwin. See license.html for usage license.