Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

FileWriter not creating file...

807580Aug 20 2010 — edited Aug 23 2010
This problem doesn't exist when I run my program on my Mac, but when I run it on my remote Centos 5.5 at Rackspace, I get the following:


java.io.FileNotFoundException: sudo /usr/share/apache-tomcat-6.0.28/webapps/AIWars/WEB-INF/classes/test.java (No such file or directory)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileWriter.<init>(Unknown Source)
at Gigabyte.Gigarun.main(Gigarun.java:96)


The only real line of consequence out of the code is:

FileWriter fw = new FileWriter("/usr/share/apache-tomcat-6.0.28/webapps/AIWars/WEB-INF/classes/test.java");

I wanted to post the whole code here but it doesn't seem to be reproducible on different systems so I am not sure how useful it would be.

Normally, this would just create a new file called test.java if it wasn't there, and if it was, it'd open it. If I create the file manually, it still reads this error, but when I do "ls DIRECTORY" where directory is the link given above in the error code, it shows me the file exists.

It does this code on my Mac just fine. I don't know why it is not doing it on this Linux server, and Im not sure how to provide you with an example set of code when it behaves differently on different platforms, which is distinctly unjavalike.

If you have any ideas as to why this is, or how to make a working example to show you all, please, let me know.

Just in case it does help, I've posted the piece of code below that this came from:
  				try {
	                        fw = new FileWriter(srcdirectory+"test.java");

                  	
  			 	fw.write(oldRev);
  				fw.close(); } catch(IOException exc) { exc.printStackTrace(); 
  				return false;}

  				 proc = 	Runtime.getRuntime().exec("javac -cp " + bhengbindirectory + ":" + apachedirectory  +      "lib/servlet-api.jar"+
  							" -d " + bindirectory + 
  							" " + srcdirectory +"test.java");
  	     
Edited by: ArkAvon on Aug 20, 2010 3:58 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 20 2010
Added on Aug 20 2010
3 comments
3,226 views