文本文件就像
"Name","Salary",
"Bernard,"200000.00"
BufferedReader br = new BufferedReader(new FileReader("file.txt"));
String line = br.readLine();
String[] splitLine = line.toString().split(",");
for (String splitValue: splitLine) {
System.out.println(""+splitValue);
}
我想展示
Name Salary
Bernard 200000.00
答案 0 :(得分:2)
Regex
方法将用于
str.replaceAll("\",\"", " ");
用空格替换每个","
。
答案 1 :(得分:0)
类似于splitValue.replace(“ \”“,”“)
您还需要在此处添加空格而不是空字符串(不确定是否是错字):
System.out.println(""+splitValue);