java - 如何编写扫描仪代码来加载先前保存在 save.txt 中的内容?

标签 java save load

我的目标是加载 save.txt 文件中的内容。我该怎么写呢?我不确定我的写入代码是否正在写入 save.txt。可以看一下吗?

else if (savePicture.isPointInElement(clickX, clickY)){
    FileWriter fw = new FileWriter("save.txt");
    for (int i = 0; i < arraysticker.length; i++){
        if (arraysticker[image]!=null){
            String name;
            int x,y;
            name = sticker.getname();
            x = sticker.getx();
            y = sticker.gety();
            fw.write(name + " " + x + " " + y + "\n");
        }
    }
}

这是我添加的“贴纸”代码之一。

if (hatSoundPlay){ //if hatSoundPlay is true
    hatsound.play(); //and a hatsound will play
    sticker sticker1 = new sticker();//creates a new sticker1
    sticker1.arraysticker(hatPicture, "hat.png", clickX, clickY);//places sticker
    image ++;//increments image by 1
    arraysticker[image] = sticker1;//puts sticker 4 into the array
    sticker11 = true;

最佳答案

FileWriter fw = new FileWriter("save.txt");
for (int i = 0; i < arraysticker.length; i++){
    if (arraysticker[image]!=null){
        String name;
        int x,y;
        name = sticker.getname();
        x = sticker.getx();
        y = sticker.gety();
        fw.write(name + " " + x + " " + y + "\n");
    }
}
**fw.flush();
fw.close();**

关于java - 如何编写扫描仪代码来加载先前保存在 save.txt 中的内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33205190/

相关文章:

java - Android 两个AsyncTasks 串行执行还是并行执行? - 第二个是卡住,但结果还可以

java - 为什么我的去除这种颜色的方法不起作用?

Python Traitsui 保存文件对话 - 覆盖

php - 如何使用jquery加载函数加载php函数?

jQuery 将 url 变量传递给 load 函数

java - Scanner.nextLine() 什么时候阻塞?

php - 以多页php形式保存用户输入数据

PHP 不使用 DOMDocument 保存

java - 负载平衡 Java 应用程序 | Ec2实例

java - java中的双括号初始化