Writing to file from within a servlet(Deployer:Tomcat)?

Your code has both "/" and the windows file separator at the start of the filename passed to getRealPath() Java interprets slashes in filenames according to the current OS.

Your code has both "/" and the windows file separator at the start of the filename passed to getRealPath(), Java interprets slashes in filenames according to the current OS. Not using the file separators might give a better result: String filename = getServletContext(). GetRealPath("/WEB-INF/XML.

Xml"); log. Debug("Using XML file: " + filename); xml_out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename),"UTF8")); Using a separate variable for the filename lets you log it so you can see unexpected results early in de development process.

This didn't work either! And I don't know how you used the log. Debug method?

Is log a standard class in java or I have to download some packages to use it? – bikashg Dec 19 '10 at 10:19 @Bikash, you can use an instance of java.util.logging. Logger or use the log4j library for instance (or for the time being simply use System.

Out) you might write the file in a different location than what you expect. – rsp Dec 19 '10 at 10:54 Yeah, the file was written somewhere else. I checked for it, and edited the path name to get the correct destination.Thanks.

– bikashg Dec 19 '10 at 13:02.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions