Oracle Fusion Middleware Java API Reference for Oracle ADF Model
11g Release 1 (11.1.1.7.0)

E10653-08

oracle.adf.model.adapter.dataformat.csv
Class CSVParser

java.lang.Object
  extended by oracle.adf.model.adapter.dataformat.csv.CSVParser

public final class CSVParser
extends java.lang.Object

Excel CSV Parser. If no encoding is passed to the constructor, the default encoding used to read the CSV file is "UTF8". Rules of Excel CSV

  • 1. Seperator character: any character, supports more than one separators. The default separator is "," (comma).
  • 2. Quote character: " or '
  • 3. Quote character itself inside quoted string: "" (double quote)
  • 4. Quote only takes effect at the first character of a value
          Examples:
            1. ,"abc 123", => abc 123
            2. ,"abc" "123', => abc "123"
            3. ,abc "123", => abc "123"
        
  • 5. Comment start characters: N/A

  • Field Summary
    static java.lang.String UTF8_ENCODING
              UTF8 encoding, used for hadling data in different languages.
     
    Constructor Summary
    CSVParser(java.io.InputStream pInputStream)
              Constructor
    CSVParser(java.io.InputStream pInputStream, java.lang.String pEnc)
              Constructor
     
    Method Summary
     java.lang.String[] getLineValues()
              Gets values of next line.
     boolean isEndOfLine()
              Tests if end of line has reached.
     boolean nextLine()
              Moves to the next line of the data.
     void setQuoteChar(char ch)
              Sets the quote character.
     void setSeparators(char[] seps)
              Sets the separator characters as a list of possible separators for the data.
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    UTF8_ENCODING

    public static final java.lang.String UTF8_ENCODING
    UTF8 encoding, used for hadling data in different languages.

    See Also:
    Constant Field Values
    Constructor Detail

    CSVParser

    public CSVParser(java.io.InputStream pInputStream)
              throws java.lang.Exception
    Constructor

    Parameters:
    pInputStream - CSV input stream
    Throws:
    java.lang.Exception - any error occurred

    CSVParser

    public CSVParser(java.io.InputStream pInputStream,
                     java.lang.String pEnc)
              throws java.lang.Exception
    Constructor

    Parameters:
    pInputStream - CSV input stream
    pEnc - character encoding
    Throws:
    java.lang.Exception - any error occurred
    Method Detail

    setSeparators

    public void setSeparators(char[] seps)
    Sets the separator characters as a list of possible separators for the data. CSV data may have more than one separators. By default this parser considers comma (,) as the data separator.

    Parameters:
    seps - Array of separator charactors.

    setQuoteChar

    public void setQuoteChar(char ch)
    Sets the quote character.

    Parameters:
    ch - Quote character.

    nextLine

    public boolean nextLine()
                     throws java.lang.Exception
    Moves to the next line of the data.

    Returns:
    returns false if the end of data reached.
    Throws:
    java.lang.Exception - any error occurred

    getLineValues

    public java.lang.String[] getLineValues()
                                     throws java.lang.Exception
    Gets values of next line.

    Returns:
    next line elements from input stream. If end of data reached, it returns null.
    Throws:
    java.lang.Exception - any error occurred

    isEndOfLine

    public boolean isEndOfLine()
    Tests if end of line has reached.

    Returns:
    true if end of line.

    Oracle Fusion Middleware Java API Reference for Oracle ADF Model
    11g Release 1 (11.1.1.7.0)

    E10653-08

    Copyright © 1997, 2013, Oracle. All rights reserved.