java:openCSV 未在递归循环中写入文件?
在我的主课中
public static void main(String[] args) {
CSVWriter writer = new CSVWriter(new FileWriter("D:\\myfilefile.csv"), '\t');
recursiveLoop(writer, 10);
}
public void function recursive(CSVWriter writer, int index){
if (index == 0){
return;
}else{
String[] entries ="TEST#LINE#".split("#");
writer.writeNext(entries);
index--;
recursiveLoop(writer, index);
}
}
但是当我打开 file.csv 时,什么也没有写!我做错了什么?
in my main class
public static void main(String[] args) {
CSVWriter writer = new CSVWriter(new FileWriter("D:\\myfilefile.csv"), '\t');
recursiveLoop(writer, 10);
}
public void function recursive(CSVWriter writer, int index){
if (index == 0){
return;
}else{
String[] entries ="TEST#LINE#".split("#");
writer.writeNext(entries);
index--;
recursiveLoop(writer, index);
}
}
howeverwhen I open my file.csv, nothing is written ! What am I doing wrong ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试在最后调用 writer.flush()
Try to call writer.flush() at the end