Search in sources :

Example 11 with CsvPreference

use of org.supercsv.prefs.CsvPreference in project openscoring by openscoring.

the class CsvUtil method getFormat.

public static CsvPreference getFormat(String delimiterChar, String quoteChar) {
    char delimiter = ',';
    char quote = '\"';
    if (delimiterChar != null) {
        delimiterChar = decodeDelimiter(delimiterChar);
        if (delimiterChar.length() != 1) {
            throw new IllegalArgumentException("Invalid CSV delimiter character: \"" + delimiterChar + "\"");
        }
        delimiter = delimiterChar.charAt(0);
    }
    if (quoteChar != null) {
        quoteChar = decodeQuote(quoteChar);
        if (quoteChar.length() != 1) {
            throw new IllegalArgumentException("Invalid CSV quote character: \"" + quoteChar + "\"");
        }
        quote = quoteChar.charAt(0);
    }
    CsvPreference format = createFormat(delimiter, quote);
    return format;
}
Also used : CsvPreference(org.supercsv.prefs.CsvPreference)

Aggregations

CsvPreference (org.supercsv.prefs.CsvPreference)11 InputStreamReader (java.io.InputStreamReader)6 IOException (java.io.IOException)5 BufferedReader (java.io.BufferedReader)3 ArrayList (java.util.ArrayList)3 CellProcessor (org.supercsv.cellprocessor.ift.CellProcessor)3 OutputStream (java.io.OutputStream)2 Test (org.junit.Test)2 CommentStartsWith (org.supercsv.comment.CommentStartsWith)2 CsvListWriter (org.supercsv.io.CsvListWriter)2 CsvMapReader (org.supercsv.io.CsvMapReader)2 ICsvMapReader (org.supercsv.io.ICsvMapReader)2 AmazonEC2ClientBuilder (com.amazonaws.services.ec2.AmazonEC2ClientBuilder)1 ImmutableParseAnalysis (com.khartec.waltz.model.catalog.ImmutableParseAnalysis)1 ParseAnalysis (com.khartec.waltz.model.catalog.ParseAnalysis)1 AwsAccountDetailDto (com.vmware.photon.controller.model.adapters.aws.dto.AwsAccountDetailDto)1 BufferedOutputStream (java.io.BufferedOutputStream)1 BufferedWriter (java.io.BufferedWriter)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1