类 CSVWriter

java.lang.Object
com.sh.common.csv.CSVWriter
所有已实现的接口:
Closeable, AutoCloseable

public class CSVWriter extends Object implements Closeable
Description: 生成CSV文件 Title:首亨软件 - CRM、TSS、ERP等信息化管理软件
  • 字段详细资料

    • INITIAL_STRING_SIZE

      public static final int INITIAL_STRING_SIZE
      另请参阅:
    • DEFAULT_ESCAPE_CHARACTER

      public static final char DEFAULT_ESCAPE_CHARACTER
      另请参阅:
    • DEFAULT_SEPARATOR

      public static final char DEFAULT_SEPARATOR
      另请参阅:
    • DEFAULT_QUOTE_CHARACTER

      public static final char DEFAULT_QUOTE_CHARACTER
      另请参阅:
    • NO_QUOTE_CHARACTER

      public static final char NO_QUOTE_CHARACTER
      另请参阅:
    • NO_ESCAPE_CHARACTER

      public static final char NO_ESCAPE_CHARACTER
      另请参阅:
    • DEFAULT_LINE_END

      public static final String DEFAULT_LINE_END
      另请参阅:
  • 构造器详细资料

    • CSVWriter

      public CSVWriter(Writer writer)
      Constructs CSVWriter using a comma for the separator.
      参数:
      writer - the writer to an underlying CSV source.
    • CSVWriter

      public CSVWriter(Writer writer, char separator)
      Constructs CSVWriter with supplied separator.
      参数:
      writer - the writer to an underlying CSV source.
      separator - the delimiter to use for separating entries.
    • CSVWriter

      public CSVWriter(Writer writer, char separator, char quotechar)
      Constructs CSVWriter with supplied separator and quote char.
      参数:
      writer - the writer to an underlying CSV source.
      separator - the delimiter to use for separating entries
      quotechar - the character to use for quoted elements
    • CSVWriter

      public CSVWriter(Writer writer, char separator, char quotechar, char escapechar)
      Constructs CSVWriter with supplied separator and quote char.
      参数:
      writer - the writer to an underlying CSV source.
      separator - the delimiter to use for separating entries
      quotechar - the character to use for quoted elements
      escapechar - the character to use for escaping quotechars or escapechars
    • CSVWriter

      public CSVWriter(Writer writer, char separator, char quotechar, String lineEnd)
      Constructs CSVWriter with supplied separator and quote char.
      参数:
      writer - the writer to an underlying CSV source.
      separator - the delimiter to use for separating entries
      quotechar - the character to use for quoted elements
      lineEnd - the line feed terminator to use
    • CSVWriter

      public CSVWriter(Writer writer, char separator, char quotechar, char escapechar, String lineEnd)
      Constructs CSVWriter with supplied separator, quote char, escape char and line ending.
      参数:
      writer - the writer to an underlying CSV source.
      separator - the delimiter to use for separating entries
      quotechar - the character to use for quoted elements
      escapechar - the character to use for escaping quotechars or escapechars
      lineEnd - the line feed terminator to use
  • 方法详细资料

    • writeAll

      public void writeAll(List<String[]> allLines)
      将list中的数据写入CSV文件
      参数:
      allLines - 存放String[]对象的List对象
    • writeColumnNames

      protected void writeColumnNames(ResultSet rs) throws SQLException
      抛出:
      SQLException
    • writeAll

      public void writeAll(ResultSet rs, boolean includeColumnNames) throws SQLException, IOException
      将ResultSet中的数据写入CSV文件中
      参数:
      rs - the recordset to write
      includeColumnNames - true if you want column names in the output, false otherwise
      抛出:
      SQLException - SQLException
      IOException - IOException
    • writeNext

      public void writeNext(String[] nextLine)
      加入新的一行
      参数:
      nextLine - a string array with each comma-separated element as a separate entry
    • processLine

      protected StringBuilder processLine(String nextElement)
    • flush

      public void flush() throws IOException
      刷新输出流
      抛出:
      IOException - IOException
    • close

      public void close() throws IOException
      关闭流及缓存空间 Close the underlying stream writer flushing any buffered content.
      指定者:
      close 在接口中 AutoCloseable
      指定者:
      close 在接口中 Closeable
      抛出:
      IOException - IOException
    • checkError

      public boolean checkError()
      Checks to see if the there has been an error in the printstream.
      返回:
      boolean
    • setResultService

      public void setResultService(ResultSetHelper resultService)