我有以下格式的数据
PAL : PAL : NF : "INCOME"."Taxable"
PAL : PAL : NF : "EXPENSES"."TotalExpenses"
PAL : PAL : NF : "EXPENSES"."Exceptional"
在java中,我只想在不进行任何格式化的情况下分隔数据,在输出中也应该出现引号。我通常使用 Univocity,在使用下面的代码时,
//Simple CSV File Read
List<String[]> allRows;
try {
CsvParserSettings settings = new CsvParserSettings();
settings.getFormat().setLineSeparator("\n");
settings.getFormat().setDelimiter(':');
CsvParser parser = new CsvParser(settings);
allRows = parser.parseAll(new FileReader(new File(csvFile)));
int i =0, cols=0;
for(String[] str:allRows){
i++;
cols = str.length;
for(String s:str)
System.out.print(s+" == ");
System.out.println("");
if(i == 10) break;
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
输出如下,句号在引号内,我希望输出像输入一样,引号应该来。
PAL == PAL == NF == INCOME"."Taxable
PAL == PAL == NF == EXPENSES"."TotalExpenses
PAL == PAL == NF == EXPENSES"."Exceptional
预期产出
PAL == PAL == NF == "INCOME"."Taxable"
PAL == PAL == NF == "EXPENSES"."TotalExpenses"
PAL == PAL == NF == "EXPENSES"."Exceptional"