我编写了一个将文本文件转换为csv格式的代码。文本文件中的项目用制表符分隔。代码中没有错误,它运行成功,但没有创建新的csv文件。请帮忙! 这是我的代码:
package prediction.convert;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class SongDataConvert {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new FileReader("data/song_data.txt"));
BufferedWriter bw = new BufferedWriter(new FileWriter("data/song_data.csv"));
String line;
while((line = br.readLine()) != null){
String[] values = line.split("\\t", -1);
bw.write(values[0] + "," + values[1] + "," + values[2] + "\n");
}
br.close();
bw.close();
}
}