Java: operation cannot be performed in file with opening user section

I am developing a game using LibGDX, and I have successfully tested it on several computers and various operating systems. I sent it to my friend to check, and he received this cryptic error when the game is trying to save.

The series of events is as follows:

- The game opens an existing save file using Gdx.files.local (path) .readString ()

-LibGDX readString closes the file when done. I checked the source check. The file never opens again.

- Some time later, the game tries to write the file and receives the following error.

java.io.FileNotFoundException: save.dat (The requested operation cannot be performed on a file with a user-mapped section open)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileWriter.<init>(Unknown Source)
at engine.Data.writeFile(Data.java:60)

writeFile is defined as follows. Line 60 is the "new FileWriter line". (For clarity, skipping logging)

public static boolean writeFile(String filename, String data) {
    boolean success = false;

    try {
        FileWriter fw = new FileWriter(filename);
        try {
            fw.write(data);
            success = true;
        } catch(Exception e) {
            success = false;
        } finally {
            fw.close();
        }
    } catch(Exception e) {
        success = false;
    }

    return success;
}

, - Windows 7, . Windows 7 .

-, , ? - ?

+4

Source: https://habr.com/ru/post/1545168/


All Articles