我正在使用BufferedReader来读取CSV文件。我拥有的csvfile是一个表,并且包含空值,因此它打印为“,”。而不是只打印空白我想放入一个“空白空间”,所以它打印出“,空白空间”。
try {
BufferedReader brd = new BufferedReader(new
FileReader(DataFile));
brd.readLine();
while (brd.ready()) {
String st = brd.readLine().trim();
oneRow = st.split(",");
Rs.add(oneRow);
System.out.println(Arrays.toString(oneRow));
}
}
答案 0 :(得分:0)
你可以在分裂前更换;即 而不是
oneRow = st.split(",");
你可以做到
oneRow = (st.startsWith(",")? "blankspace," + st.substring(1):st).replaceAll(",,", ",blankspace,").split(",");