|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.aliasi.util.CommaSeparatedValues
public class CommaSeparatedValues
A CommaSeparatedValues object represents a
two-dimensional array of strings which may be read and written in
comma-separated-value string representation. The CSV encoding
is general enough to encode arbitary ragged two-dimensional arrays
of strings.
The CSV notation is character oriented, so any data read to or
from files or streams must use a character encoding. The behavior
of reads and writes for unknown characters is determined by
InputStreamReader and OutputStreamWriter, constructed
with the user-specified character set.
The CSV format is row-oriented, consisting of a number of rows, followed by the end of the stream. Each row consists of a number of elements separated by commas. The rows are not required to contain the same number of elements.
An element may be plain or quoted. Plain elements consist of a
sequence of characters not containing any double quote
("), comma (,), or newline
(\n) characters. Any leading or trailing whitespace
is trimmed to produce the element string. For CSV processing, a
whitespace character may be either a space (' ') or a
tab (Java literal '\t') character.
Quoted elements consist of a sequence of characters surrounded by double quotes. The elements between the double quotes may include comma or newline characters. Double quotes may be included, but must be escaped with another double quote. Any space before or after the quote symbols is ignored, but any whitespace between the element-wrapping quotes is included in the element string.
| Constructor Summary | |
|---|---|
CommaSeparatedValues(File file,
String charset)
Construct a comma-separated values array from the specified file using the specified character set. |
|
CommaSeparatedValues(InputStream in,
String charset)
Construct a comma-separated values array from the specified input stream using the specified character set. |
|
CommaSeparatedValues(Reader reader)
Construct a comma-separated values array from the specified reader. |
|
| Method Summary | |
|---|---|
String[][] |
getArray()
Returns the underlying array for this comma-separated values object. |
void |
toFile(File file,
String charset)
Write this comma-separated values object to the specified file using the specified charset. |
void |
toStream(OutputStream out,
String charset)
Write this comma-separated values object to the specified output stream using the specified charset. |
String |
toString()
Returns a string-based representation of this comma-separated values object. |
void |
toWriter(Writer writer)
Write this comma-separated values object to the specified writer. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public CommaSeparatedValues(File file,
String charset)
throws IOException
file - File from which to read.charset - Encoding of characters in the stream.
IOException - If there is an underlying I/O error.
IllegalArgumentException - If the stream of characters
produced by the reader is not a well-defined CSV string.
public CommaSeparatedValues(InputStream in,
String charset)
throws IOException
in - Input stream from which to read.charset - Encoding of characters in the stream.
IOException - If there is an underlying I/O error.
IllegalArgumentException - If the stream of characters
produced by the reader is not a well-defined CSV string.
public CommaSeparatedValues(Reader reader)
throws IOException
reader - Reader from which the CSV object will be read.
IOException - If there is an underlying I/O error.
IllegalArgumentException - If the stream of characters
produced by the reader is not a well-defined CSV string.| Method Detail |
|---|
public String[][] getArray()
public void toFile(File file,
String charset)
throws IOException
?) character.
file - File to which this CSV object is written.charset - Character encoding to use for characters.
IOException - If there is an underlying I/O exception.
public void toStream(OutputStream out,
String charset)
throws IOException
?) character.
out - Stream to which this CSV object is written.charset - Character encoding to use for characters.
IOException - If there is an underlying I/O exception.
public void toWriter(Writer writer)
throws IOException
writer - Writer to which this CSV object is written.
IOException - If there is an underlying I/O exception.public String toString()
toString in class Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||