gpt4 book ai didi

java - printwriter 对象未打印出来

转载 作者:行者123 更新时间:2023-12-02 05:37:43 29 4
gpt4 key购买 nike

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

最佳答案

您似乎忘记在 writer 上调用 flushclose 。如果没有它,一些临时存储在缓冲区中的字符将不会发送到文件。

关于java - printwriter 对象未打印出来,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24814899/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com