java:openCSV不能在递归循环中写入文件?

时间:2010-11-06 02:12:00

标签: 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时,什么都写不出来!我做错了什么?

1 个答案:

答案 0 :(得分:2)

尝试在最后调用writer.flush()