[Advanced-java] FileOutputStream & real path

Singh, Shiv P. ssingh4 at telcordia.com
Thu Jul 24 19:34:40 2003


The space should not be a problem, but not escaping the backslash
characters will give you a compilation error.

Code:
      new FileOutputStream( "c:\program files\test.txt" );

javac result:

	Echo.java:17: illegal escape character
      	new FileOutputStream( "c:\program files\test.txt" );

Pal

-----Original Message-----
From: Marco Ferretti [mailto:marco.ferretti@jrc.it] 
Sent: Thursday, July 24, 2003 1:14 PM
To: advanced-java@lists.xcf.berkeley.edu
Subject: [Advanced-java] FileOutputStream & real path


Hi there guys.

I have a question for you. 

I have an utility that reads data from database, plots it and then saves the
plot as a jpeg for future needs. 

I really had no problems in debugging & using the util since I needed to
publish theese plots on the web.

My question is 

    since I create the file as new FileOutPutStream(basepath +"img/"+
fileName)

what happens if some windows fan tries to run from (say tomcat ?) C:\Program
Files\Apache\Tomcat ?

If I get the base path from the web server as session.getServletContext()
getRealPath(".") the server's supposed to reply "C:\Program
Files\Apache\Tomcat\webapps\yourApp\." , so I would end up with 

FileOutPutStream("C:\Program Files\Apache\Tomcat\webapps\yourApp\img/"+
fileName) .

Do you think the extra space between Program and Files give me problems ?
_______________________________________________
Advanced-java mailing list
Advanced-java@lists.xcf.berkeley.edu
http://lists.xcf.berkeley.edu/mailman/listinfo/advanced-java