类 CSVReader

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

public class CSVReader extends Object implements Closeable
Description: 读取CSV文件 Title:首亨软件 - CRM、TSS、ERP等信息化管理软件
  • 字段概要

    字段
    修饰符和类型
    字段
    说明
    static final int
     
  • 构造器概要

    构造器
    构造器
    说明
     
    CSVReader(Reader reader)
    Constructs CSVReader using a comma for the separator.
    CSVReader(Reader reader, char separator)
    Constructs CSVReader with supplied separator.
    CSVReader(Reader reader, char separator, char quotechar)
    Constructs CSVReader with supplied separator and quote char.
    CSVReader(Reader reader, char separator, char quotechar, boolean strictQuotes)
    Constructs CSVReader with supplied separator, quote char and quote handling behavior.
    CSVReader(Reader reader, char separator, char quotechar, char escape)
    Constructs CSVReader with supplied separator and quote char.
    CSVReader(Reader reader, char separator, char quotechar, char escape, int line)
    Constructs CSVReader with supplied separator and quote char.
    CSVReader(Reader reader, char separator, char quotechar, char escape, int line, boolean strictQuotes)
    Constructs CSVReader with supplied separator and quote char.
    CSVReader(Reader reader, char separator, char quotechar, char escape, int line, boolean strictQuotes, boolean ignoreLeadingWhiteSpace)
    Constructs CSVReader with supplied separator and quote char.
    CSVReader(Reader reader, char separator, char quotechar, int line)
    Constructs CSVReader with supplied separator and quote char.
     
  • 方法概要

    修饰符和类型
    方法
    说明
    void
    Closes the underlying reader.
    boolean
     
    Reads the entire file into a List with each element being a String[] of tokens
    Reads the next line from the buffer and converts to a string array.

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 字段详细资料

    • DEFAULT_SKIP_LINES

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

    • CSVReader

      public CSVReader(Reader reader)
      Constructs CSVReader using a comma for the separator.
      参数:
      reader - the reader to an underlying CSV source.
    • CSVReader

      public CSVReader(InputStream is)
    • CSVReader

      public CSVReader(String url)
    • CSVReader

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

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

      public CSVReader(Reader reader, char separator, char quotechar, boolean strictQuotes)
      Constructs CSVReader with supplied separator, quote char and quote handling behavior.
      参数:
      reader - the reader to an underlying CSV source.
      separator - the delimiter to use for separating entries
      quotechar - the character to use for quoted elements
      strictQuotes - sets if characters outside the quotes are ignored
    • CSVReader

      public CSVReader(Reader reader, char separator, char quotechar, char escape)
      Constructs CSVReader with supplied separator and quote char.
      参数:
      reader - the reader to an underlying CSV source.
      separator - the delimiter to use for separating entries
      quotechar - the character to use for quoted elements
      escape - the character to use for escaping a separator or quote
    • CSVReader

      public CSVReader(Reader reader, char separator, char quotechar, int line)
      Constructs CSVReader with supplied separator and quote char.
      参数:
      reader - the reader to an underlying CSV source.
      separator - the delimiter to use for separating entries
      quotechar - the character to use for quoted elements
      line - the line number to skip for start reading
    • CSVReader

      public CSVReader(Reader reader, char separator, char quotechar, char escape, int line)
      Constructs CSVReader with supplied separator and quote char.
      参数:
      reader - the reader to an underlying CSV source.
      separator - the delimiter to use for separating entries
      quotechar - the character to use for quoted elements
      escape - the character to use for escaping a separator or quote
      line - the line number to skip for start reading
    • CSVReader

      public CSVReader(Reader reader, char separator, char quotechar, char escape, int line, boolean strictQuotes)
      Constructs CSVReader with supplied separator and quote char.
      参数:
      reader - the reader to an underlying CSV source.
      separator - the delimiter to use for separating entries
      quotechar - the character to use for quoted elements
      escape - the character to use for escaping a separator or quote
      line - the line number to skip for start reading
      strictQuotes - sets if characters outside the quotes are ignored
    • CSVReader

      public CSVReader(Reader reader, char separator, char quotechar, char escape, int line, boolean strictQuotes, boolean ignoreLeadingWhiteSpace)
      Constructs CSVReader with supplied separator and quote char.
      参数:
      reader - the reader to an underlying CSV source.
      separator - the delimiter to use for separating entries
      quotechar - the character to use for quoted elements
      escape - the character to use for escaping a separator or quote
      line - the line number to skip for start reading
      strictQuotes - sets if characters outside the quotes are ignored
      ignoreLeadingWhiteSpace - it true, parser should ignore white space before a quote in a field
  • 方法详细资料

    • readAll

      public List<String[]> readAll() throws IOException
      Reads the entire file into a List with each element being a String[] of tokens
      返回:
      a List of String[], with each String[] representing a line of the file
      抛出:
      IOException - IOException
    • readNext

      public String[] readNext() throws IOException
      Reads the next line from the buffer and converts to a string array.
      返回:
      a string array with each comma-separated element as a separate entry.
      抛出:
      IOException - IOException
    • close

      public void close() throws IOException
      Closes the underlying reader.
      指定者:
      close 在接口中 AutoCloseable
      指定者:
      close 在接口中 Closeable
      抛出:
      IOException - IOException
    • hasNext

      public boolean hasNext()