原创

为什么我每次执行 Java 程序时都会收到这些奇怪的单词?

温馨提示:
本文最后更新于 2024年04月12日,已超过 48 天没有更新。若文章内的图片失效(无法正常加载),请留言反馈或直接联系我

enter image description here

Every time I try to run this code

import java.io.File;
import java.util.Formatter;
import java.util.Scanner;

public class training{
    public static void main(String[] args) {
        try {
            Formatter f = new Formatter("testing.txt");
            f.format("%s %s %s", "1", "John", "Smith \r\n");
            f.format("%s %s %s", "2", "Amy", "Brown");
            f.close();

            File file = new File("testing.txt");
            Scanner sc = new Scanner(file);
            while (sc.hasNext()) {
                System.out.println(sc.next());
            }
            sc.close();
        } catch (Exception e) {
            System.out.println("ERROR!");
        }
    }
}

I'm getting, yes, the correct result, but before that I'm getting some paceStorage and x5credhat.java I don't know why, how can I delete these strange characters ?

正文到此结束
热门推荐
本文目录