|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.hpi.fgis.dude.util.csv.CSVReader
public class CSVReader
CSVReader
reads CSV
formatted data.
Field Summary | |
---|---|
static char |
DEFAULT_ESCAPE_CHARACTER
The default escape character. |
static char |
DEFAULT_QUOTE_CHARACTER
The default quote character. |
static char |
DEFAULT_SEPARATOR
The default separator character. |
Constructor Summary | |
---|---|
CSVReader(Reader reader)
Initializes a CSVReader with the given Reader . |
Method Summary | |
---|---|
protected boolean |
canBeEscaped(char ch)
Checks whether the passed character can be escaped. |
void |
close()
Closes the internally used reader. |
int |
getColumnCount()
Returns the number of columns of the currently processed data source. |
protected String[] |
getDataLine(String str)
Extracts the data out of the passed String. |
char |
getEscapeCharacter()
Returns the current escape character. |
char |
getQuoteCharacter()
Returns the current quote character. |
char |
getSeparator()
Returns the current separator character. |
boolean |
isClosed()
Checks whether the reader was already closed. |
String[] |
nextLine()
Returns the data of the next line or null , if the end of the data source was reached. |
void |
setColumnCount(int columnCount)
Sets the column count. |
void |
setEscapeCharacter(char escapeCharacter)
Sets the escape character. |
void |
setQuoteCharacter(char quoteCharacter)
Sets the quote character. |
void |
setSeparator(char separator)
Sets the separator character. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final char DEFAULT_SEPARATOR
public static final char DEFAULT_QUOTE_CHARACTER
public static final char DEFAULT_ESCAPE_CHARACTER
Constructor Detail |
---|
public CSVReader(Reader reader)
CSVReader
with the given Reader
.
reader
- The reader that is used internally.Method Detail |
---|
public int getColumnCount()
public void setColumnCount(int columnCount)
columnCount
- The column count.protected boolean canBeEscaped(char ch)
ch
- The character that shall be checked.
true
, if the passed character can be escaped; otherwise false
.protected String[] getDataLine(String str) throws ParseException
str
- The String that shall be parsed.
ParseException
- If an error occurs due to a wrong format.public String[] nextLine() throws IOException, ParseException
null
, if the end of the data source was reached.
null
, if the end of the data source was reached.
IOException
- If an error occurs during the reading process.
ParseException
- If an error occurs due to wrong formats within the next line.
IllegalStateException
- If the CSVReader
was already closed.public boolean isClosed()
true
, if the reader was already closed; otherwise false
.public void close() throws IOException
close
in interface Closeable
IOException
- If an error occurs during the closing process.public char getSeparator()
public void setSeparator(char separator)
separator
- The separator character to set.public char getQuoteCharacter()
public void setQuoteCharacter(char quoteCharacter)
quoteCharacter
- The quote character to set.public char getEscapeCharacter()
public void setEscapeCharacter(char escapeCharacter)
escapeCharacter
- The escape character to set.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |