net.sf.jmatchparser.util.csv
Class FixedWidthCSVWriter

java.lang.Object
  extended by net.sf.jmatchparser.util.csv.AbstractCSVWriter
      extended by net.sf.jmatchparser.util.csv.FixedWidthCSVWriter

public class FixedWidthCSVWriter
extends AbstractCSVWriter

Class to create fixed width CSV (Comma Separated Value) files, where every column has a fixed width and may optionally additionally delimited by separator characters.


Constructor Summary
FixedWidthCSVWriter(OutputStream out, String charsetName, FixedWidthColumn... columns)
          Create a new CSV writer that writes to the given stream in the given charset using the given columns and no separators.
FixedWidthCSVWriter(OutputStream out, String charsetName, int... widths)
          Create a new CSV writer that writes to the given stream in the given charset using left-aligned space-padded columns only and no separators.
FixedWidthCSVWriter(OutputStream out, String charsetName, String... columnSpecs)
          Create a new CSV writer that writes to the given stream in the given charset using columns parsed from the given column specs and no separators.
FixedWidthCSVWriter(OutputStream out, String charsetName, String prefix, String separator, String suffix, FixedWidthColumn... columns)
          Create a new CSV writer that writes to the given stream in the given charset using the given columns and separators.
FixedWidthCSVWriter(Writer w, FixedWidthColumn... columns)
          Create a new CSV writer that writes to the given Writer using the given columns and no separators.
FixedWidthCSVWriter(Writer w, int... widths)
          Create a new CSV writer that writes to the given Writer using left-aligned space-padded columns only and no separators.
FixedWidthCSVWriter(Writer w, String... columnSpecs)
          Create a new CSV writer that writes to the given Writer using columns parsed from the given column specs and no separators.
FixedWidthCSVWriter(Writer w, String prefix, String separator, String suffix, FixedWidthColumn... columns)
          Create a new CSV writer that writes to the given Writer using the given columns and separators.
 
Method Summary
 void close()
          Close this CSV writer.
 void flush()
          Flush this CSV writer.
 void setTruncateValues(boolean truncateValues)
          Set whether overlong values should be truncated automatically.
 void write(String... record)
          Write a record (line) into this CSV file.
 
Methods inherited from class net.sf.jmatchparser.util.csv.AbstractCSVWriter
write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FixedWidthCSVWriter

public FixedWidthCSVWriter(Writer w,
                           int... widths)
Create a new CSV writer that writes to the given Writer using left-aligned space-padded columns only and no separators.

Parameters:
w - the writer to write to.
widths - The width of each column

FixedWidthCSVWriter

public FixedWidthCSVWriter(Writer w,
                           String... columnSpecs)
Create a new CSV writer that writes to the given Writer using columns parsed from the given column specs and no separators.

Parameters:
w - the writer to write to.
columnSpecs - The format specification of each column

FixedWidthCSVWriter

public FixedWidthCSVWriter(Writer w,
                           FixedWidthColumn... columns)
Create a new CSV writer that writes to the given Writer using the given columns and no separators.

Parameters:
w - the writer to write to.
columns - The format of each column

FixedWidthCSVWriter

public FixedWidthCSVWriter(Writer w,
                           String prefix,
                           String separator,
                           String suffix,
                           FixedWidthColumn... columns)
Create a new CSV writer that writes to the given Writer using the given columns and separators.

Parameters:
w - the writer to write to.
prefix - The prefix to add to each line
separator - The separator to add between each field
suffix - The suffix to add to each line
columns - The format of each column

FixedWidthCSVWriter

public FixedWidthCSVWriter(OutputStream out,
                           String charsetName,
                           int... widths)
                    throws UnsupportedEncodingException
Create a new CSV writer that writes to the given stream in the given charset using left-aligned space-padded columns only and no separators.

Parameters:
out - Output stream
charsetName - charset
widths - The width of each column
Throws:
UnsupportedEncodingException

FixedWidthCSVWriter

public FixedWidthCSVWriter(OutputStream out,
                           String charsetName,
                           String... columnSpecs)
                    throws UnsupportedEncodingException
Create a new CSV writer that writes to the given stream in the given charset using columns parsed from the given column specs and no separators.

Parameters:
out - Output stream
charsetName - charset
columnSpecs - The format specification of each column
Throws:
UnsupportedEncodingException

FixedWidthCSVWriter

public FixedWidthCSVWriter(OutputStream out,
                           String charsetName,
                           FixedWidthColumn... columns)
                    throws UnsupportedEncodingException
Create a new CSV writer that writes to the given stream in the given charset using the given columns and no separators.

Parameters:
out - Output stream
charsetName - charset
columns - The format of each column
Throws:
UnsupportedEncodingException

FixedWidthCSVWriter

public FixedWidthCSVWriter(OutputStream out,
                           String charsetName,
                           String prefix,
                           String separator,
                           String suffix,
                           FixedWidthColumn... columns)
                    throws UnsupportedEncodingException
Create a new CSV writer that writes to the given stream in the given charset using the given columns and separators.

Parameters:
out - Output stream
charsetName - charset
prefix - The prefix to add to each line
separator - The separator to add between each field
suffix - The suffix to add to each line
columns - The format of each column
Throws:
UnsupportedEncodingException
Method Detail

flush

public void flush()
           throws IOException
Description copied from class: AbstractCSVWriter
Flush this CSV writer.

Specified by:
flush in class AbstractCSVWriter
Throws:
IOException

close

public void close()
           throws IOException
Description copied from class: AbstractCSVWriter
Close this CSV writer.

Specified by:
close in class AbstractCSVWriter
Throws:
IOException

setTruncateValues

public void setTruncateValues(boolean truncateValues)
Set whether overlong values should be truncated automatically. If disabled, an exception will be thrown.


write

public void write(String... record)
           throws IOException
Description copied from class: AbstractCSVWriter
Write a record (line) into this CSV file.

Specified by:
write in class AbstractCSVWriter
Throws:
IOException


Copyright © 2011. All Rights Reserved.