java – 将输出数据写入文本文件会在文本文件中产生不完整的结果

我有14个列表,每个列表都有数字或字符串数​​据.每个列表的大小是32561.我必须输出一个格式为的文件:

list1_element1   list2_element1.......................list14_element1
list1_element2   list2_element2.......................list14_element2
.
.
.
.
.
list1_element32561   list2_element32561.......................list14_element32561

输出文件中的每个元素由制表符空格分隔.我在Java中这样做了.

        out = new BufferedWriter(new FileWriter(fileName));
        for(int i=0; i<32561; i++) {
        out.write(firstList.get(i));
        out.write("\t");
        out.write(secondList.get(i));
        out.write("\t");
        out.write(thirdList.get(i));
        out.write("\t");
        out.write(fourthList.get(i));
        out.write("\t");
        out.write(fifthList.get(i));
        out.write("\t");
        out.write(sixthList.get(i));
        out.write("\t");
        out.write(seventhList.get(i));
        out.write("\t");
        out.write(eighthList.get(i));
        out.write("\t");
        out.write(ninthList.get(i));
        out.write("\t");
        out.write(tenthList.get(i));
        out.write("\t");
        out.write(eleventhList.get(i));
        out.write("\t");
        out.write(twelvethList.get(i));
        out.write("\t");
        out.write(thirteenthList.get(i));
        out.write("\t");
        out.write(fourteenthList.get(i));
            out.write("\t");
        out.write(fifteenthList.get(i));

        out.newLine();
    }
}

我的程序只打印32441行,最后一行只包含6列.我不明白为什么.有人可以帮忙吗?

解决方法:

你没有关闭作家.

上一篇:kvm虚拟化存储管理


下一篇:java – 即使在.flush()/.close()之后,FileWriter也不会写入文件