Java – writing output data to a text file produces incomplete results in the text file

I have 14 lists, each with numeric or string data The size of each list is 32561 I must output a file in the format:

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

Each element in the output file is separated by a tab space I did this in 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();
    }
}

My program only prints 32441 lines, and the last line contains only 6 columns I don't understand why Can I help you?

Solution

You didn't shut down the writer

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>