Example usage for org.apache.commons.csv CSVStrategy setIgnoreLeadingWhitespaces

List of usage examples for org.apache.commons.csv CSVStrategy setIgnoreLeadingWhitespaces

Introduction

In this page you can find the example usage for org.apache.commons.csv CSVStrategy setIgnoreLeadingWhitespaces.

Prototype

public void setIgnoreLeadingWhitespaces(boolean ignoreLeadingWhitespaces) 

Source Link

Usage

From source file:uk.co.droidinactu.common.file.DelimitedFile.java

public ArrayList<String> convertLineToFields(String line) {
    // Log.w("DelimitedFile", "convertLineToFields converting line [" + line +
    // "] to fields");
    ArrayList<String> alFields = new ArrayList<String>();

    CSVStrategy csvStrat = new CSVStrategy(this.m_sDelimiter.charAt(0), '\"', '#');
    csvStrat.setIgnoreLeadingWhitespaces(true);
    CSVParser csvParser = new CSVParser(new StringReader(line), csvStrat);
    String[][] st;//from ww w.jav a2s .  co m
    try {
        st = csvParser.getAllValues();
        for (String[] element : st) {
            for (int tokenNbr = 0; tokenNbr < element.length; tokenNbr++) {
                alFields.add(element[tokenNbr]);
            }
        }
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return alFields;
}