Java Code Examples for au.com.bytecode.opencsv.CSVWriter.DEFAULT_QUOTE_CHARACTER

The following are Jave code examples for showing how to use DEFAULT_QUOTE_CHARACTER of the au.com.bytecode.opencsv.CSVWriter class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: java-aws-mturk   File: HITDataCSVReader.java   Source Code and License Vote up 6 votes
public HITDataCSVReader(String fileName, char separator) throws IOException {
    super();
    InputStreamReader input = new InputStreamReader(new FileInputStream(fileName), "UTF-8");
    CSVReader csvReader = new CSVReader(input, separator, CSVWriter.DEFAULT_QUOTE_CHARACTER);
    String[] row = null;
    
    try {
      // read all lines but skip header rows that got appended repetitively
      while ((row = csvReader.readNext()) != null) {
        if (fieldNames == null) {
          fieldNames = row;
          rows.add(fieldNames); // header is at index 0
        }
        else if (!Arrays.equals(fieldNames, row)) {
          rows.add(row);
        }
      }
    }
    finally {
      csvReader.close();
    }
}
 
Example 2
Project: mturksdk-java-code-maven   File: HITDataCSVReader.java   Source Code and License Vote up 6 votes
public HITDataCSVReader(String fileName, char separator) throws IOException {
    super();
    InputStreamReader input = new InputStreamReader(new FileInputStream(fileName), "UTF-8");
    CSVReader csvReader = new CSVReader(input, separator, CSVWriter.DEFAULT_QUOTE_CHARACTER);
    String[] row = null;
    
    try {
      // read all lines but skip header rows that got appended repetitively
      while ((row = csvReader.readNext()) != null) {
        if (fieldNames == null) {
          fieldNames = row;
          rows.add(fieldNames); // header is at index 0
        }
        else if (!Arrays.equals(fieldNames, row)) {
          rows.add(row);
        }
      }
    }
    finally {
      csvReader.close();
    }
}
 
Example 3
Project: java-aws-mturk   File: HITDataCSVWriter.java   Source Code and License Vote up 5 votes
protected synchronized CSVWriter getWriter() throws IOException {
    if (this.csvWriter == null) {
        FileOutputStream fos = new FileOutputStream(this.fileName, appendToFile); // always append, 
        OutputStreamWriter writer = new OutputStreamWriter(fos, "UTF-8");
        this.csvWriter = new CSVWriter( writer,
            separator,
            useQuotes ? CSVWriter.DEFAULT_QUOTE_CHARACTER : CSVWriter.NO_QUOTE_CHARACTER,
            System.getProperty("line.separator"));
    }
    return this.csvWriter;
}
 
Example 4
Project: mturksdk-java-code-maven   File: HITDataCSVWriter.java   Source Code and License Vote up 5 votes
protected synchronized CSVWriter getWriter() throws IOException {
    if (this.csvWriter == null) {
        FileOutputStream fos = new FileOutputStream(this.fileName, appendToFile); // always append, 
        OutputStreamWriter writer = new OutputStreamWriter(fos, "UTF-8");
        this.csvWriter = new CSVWriter( writer,
            separator,
            useQuotes ? CSVWriter.DEFAULT_QUOTE_CHARACTER : CSVWriter.NO_QUOTE_CHARACTER,
            System.getProperty("line.separator"));
    }
    return this.csvWriter;
}