org.apache.commons.csv.writer
Class CSVConfigGuesser
java.lang.Object
org.apache.commons.csv.writer.CSVConfigGuesser
public class CSVConfigGuesser
extends java.lang.Object
Tries to guess a config based on an InputStream.
protected CSVConfig | config - The found config
|
private boolean | hasFieldHeader - if the file has a field header (need this info, to be able to guess better)
Defaults to false
|
private InputStream | in - The stream to read
|
config
protected CSVConfig config
The found config
hasFieldHeader
private boolean hasFieldHeader
if the file has a field header (need this info, to be able to guess better)
Defaults to false
in
private InputStream in
The stream to read
CSVConfigGuesser
public CSVConfigGuesser()
CSVConfigGuesser
public CSVConfigGuesser(InputStream in)
in
- the inputstream to guess from
analyseLines
protected void analyseLines(String[] lines)
getInputStream
protected InputStream getInputStream()
Allow override.
- the inputstream that was set.
guess
public CSVConfig guess()
Guess the config based on the first 10 (or less when less available)
records of a CSV file.
guessFieldSeperator
protected void guessFieldSeperator(String[] lines)
guessFixedWidth
protected void guessFixedWidth(String[] lines)
Guess if this file is fixedwidth.
Just basing the fact on all lines being of the same length
guessFixedWidthSeperator
protected void guessFixedWidthSeperator(String[] lines)
hasFieldHeader
public boolean hasFieldHeader()
- if the field uses a field header. Defaults to false.
setHasFieldHeader
public void setHasFieldHeader(boolean hasFieldHeader)
Specify if the CSV file has a field header
hasFieldHeader
- true or false
setInputStream
public void setInputStream(InputStream in)