printwriter对象没有打印出来

时间:2014-07-17 23:03:25

标签: java javascript methods printwriter

我的PrintWriter对象编写器的print()方法无法正常工作,我导入了所有相应的类,但CSV文件一直空白。有人可以告诉我原因吗?

public class StateStats {
    static String pathto = "....";

    public static void main(String[] args) throws FileNotFoundException, IOException {
       ReadFile st = new ReadFile(pathto+"stateAbbrev.csv");
       ReadFile abPop = new ReadFile(pathto+"AbbrevPop.csv");      
       ReadFile Perc = new ReadFile(pathto+"PopPercentAlpha.dat");


       PrintWriter writer = new PrintWriter(pathto+"StateAbbPop.csv","UTF-8");

       //this is the header for our new CSV file
       writer.write("State, Abbrev, Population, %of US");
       writer.write("\n");
    }
}

1 个答案:

答案 0 :(得分:2)

您似乎忘了在作家身上调用flushclose。没有它,一些临时存储在缓冲区中的字符将不会被发送到文件。