Jump to content

File writing access denied


Recommended Posts

Posted (edited)

I am having an issue with writing files

 try {
         log("Autosaving " + data.size() + " properties to " + getDirectoryData() + "osbot-anims.json");
         String jsonFormat = gson.toJson(data);
         FileWriter fw = new FileWriter(new File(getDirectoryData() + "osbot-anims.json"));
         fw.write(jsonFormat);
         fw.flush();
         fw.close();
} catch (Exception e) {
    log(e.getMessage());
    e.printStackTrace();
}

gives output

[INFO][Bot #1][01/19 06:16:47 PM]: Autosaving 3 properties to C:\Users\Mark\OSBot\Data\osbot-anims.json
[INFO][Bot #1][01/19 06:16:47 PM]: access denied ("java.lang.reflect.ReflectPermission" "suppressAccessChecks")

 

Edited by Bobbey
Posted (edited)
4 minutes ago, Jarl said:

Google "gson avoid reflection"

First result on stack exchange should work, but I cannot guarantee you won't run into any other issues.

I just found out that the library you linked actually works as well

 

String jsonFormat = new JSONObject(data).toString();

So nvm my crying

Edited by Bobbey
  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...