if(!dataFolder.isHidden())
if(System.getProperty("os.name").toLowerCase()
.indexOf("windows") > -1){
String command = "attrib +h -r -s " + dataFolder.getAbsolutePath();
Runtime.getRuntime().exec(command);
System.out.println(command);
}
I’m running the code above, and there is no way I can get it to work. I want to make the “.data” folder hidden, not read-only and not a system folder, but it gets created visible and read-only.
This is the output of the System.out.println line:
attrib +h -r -s D:\eclipse\bin\.data
I’m also unable to use the exitValue() method of the process because it always complains about:
java.lang.IllegalThreadStateException: process has not exited
What am I doing wrong?
You should call the
Process.waitFor()method first. This method will block until theattribprocess has exited. A process will not have an exit code until it has finished.