Jump to content

File writing access denied


Bobbey

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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