繁体   English   中英

printwriter对象未打印出来

[英]printwriter object not printing out

我的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");
    }
}

看来您忘记了调用flush或在writer上close 没有它,某些存储在缓冲区字符中的临时字符将不会发送到文件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM