Error reading if file. arff exists or not

0

I'm developing a JAVA robot along with the Robocode framework and WEKA. Whenever I try to check if the ".arff" file exists, it always gives me the same error.

  

Round 1 initializing ..

     

Let the games begin!

     

Preventing Interative_NEWVERSION.NewRobot_Interative * from access:   ("java.io.FilePermission"   "C: \ Users \ JoseDias \ Documents \ NetBeansProjects \ InterativePower.arff"   "read"). You can only read files in your own root directory.

     

.Interative_NEWVERSION.NewRobot_Interative * has caused a security   violation. This robot has been banned and will not be allowed to   participate in battles.

     

Interative_NEWVERSION.NewRobot_Interative *: Exception:   java.security.AccessControlException: access denied   ("java.io.FilePermission"   "C: \ Users \ JoseDias \ Documents \ NetBeansProjects \ InterativePower.arff"   "read")

The next line is the line that I use to check whether or not the file exists in a given location.

@Override
public boolean datasetExists(String path) {

    File dc = new File(path);
  return   dc.exists();


}

What could be the related problem?

    
asked by anonymous 09.07.2017 / 21:19

1 answer

1

Friend, your code is not allowed to access the file.

add the following lines below the dc reference variable:

    dc.setReadable(Boolean.FALSE);
    dc.setWritable(Boolean.FALSE);
    dc.setExecutable(Boolean.FALSE);

Why FALSE? A: Because setting false, you tell the system that you want everyone to have access to the file. If you enter True, only the owner of the file will have access, which is strange as opposed to the default for boolean cases, but that's fine.

Source: link

    
09.07.2017 / 22:42