gpt4 book ai didi

java - "The system cannot find the file specified"用于 .out 和 .in 扩展名

转载 作者:行者123 更新时间:2023-12-02 08:43:45 30 4
gpt4 key购买 nike

我有一个像这样的BufferedReaderBufferedWriter(评论者要求查看整个代码)来测试一些训练页面:

    public static void main(String[] args) throws IOException {
BufferedReader bf = new BufferedReader(new FileReader("inputFile.in"));
PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter("inputFile.out")));

int N = Integer.parseInt(bf.readLine());

int[] dayCount = {0, 0, 0, 0, 0, 0, 0}; //Line 19

int day = 0;
for (int year = 1990; year < 1990 + N; year++) {
for (int month = 1; month <= 12; month++) {
if (month == 2) {
if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) {
dayCount[(day + 13) % 7]++;
day += 29;
} else {
dayCount[(day + 13) % 7]++;
day += 28;
}
}
else if (month == 4 || month == 6 || month == 9 || month == 11) {
dayCount[(day + 13) % 7]++;
day += 30;
}
else {
dayCount[(day + 13) % 7]++;
day += 31;
}
}
}
for (int i = 0; i < 7; i++) {
if (i < 6)
pw.print(dayCount[(i + 6) % 7] + " ");
else
pw.print(dayCount[(i + 6) % 7]);
}
pw.println();
pw.close();
}

我目前正在使用 VS Code,当我运行代码时,会出现一个弹出窗口(我不知道如何重现),内容大致如下:“市场有一个扩展可以帮助带有 .out 文件扩展名。”我查看了扩展名,然后用 Google 搜索,但找不到 .in.out 文件的扩展名。我想要一个的原因是因为即使我在当前工作目录中创建了文件,也会引发错误。这是错误:

Exception in thread "main" java.io.FileNotFoundException: inputFile.in (The system cannot find the file specified)
at java.base/java.io.FileInputStream.open0(Native Method)
at java.base/java.io.FileInputStream.open(FileInputStream.java:212)
at java.base/java.io.FileInputStream.<init>(FileInputStream.java:154)
at java.base/java.io.FileInputStream.<init>(FileInputStream.java:109)
at java.base/java.io.FileReader.<init>(FileReader.java:60)
at iotests.iotests.main(ioTests.java:19)

我已经评论了上面的第 19 行。

最佳答案

这是因为你的文件扩展名很奇怪,VSCode不知道哪个程序可以打开它,所以,它只是提示你在marketPlace中找到某个程序来打开它,仅此而已。所以,停止使用 'inputFile.in'、'inputFile.out'、'.in'、'.out' 的名称文件扩展名,只是“.txt”。

关于java - "The system cannot find the file specified"用于 .out 和 .in 扩展名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61220125/

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