Java Write Permission



I deployed my JAX-WS server. Problem is I cannot either create or modify files from the Java code. I mean this code doesn’t create a new folder:
File f = new File("/home/ubuntu/workspace/testfolder); f.mkdirs();
Running sudo java ... command doesn’t change anything too.

How can I be able to write to the certain folder?
Thanks for the response.


I see two possible problems here. First, you’re missing a quote after testfolder. Second, and I’m not positive, but I think Java might be misinterpreting testfolder to be a file. You should be able to fix this by appending a trailing slash like this:
File f = new File("/home/ubuntu/workspace/testfolder/");


The quote is just mistyping (I texted code, not copied).
About interpreting “testfolder” as a file. The code above works perfectly on my laptop. With or without trailing slash. As well as it doesn’t work on Cloud9 (both with and without slash). This was the point when I started to think the problem was with permissions, not code.
Also, I have no problems reading files using File class.