aspose file tools*
The moose likes Spring and the fly likes unble to write the data into file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "unble to write the data into file" Watch "unble to write the data into file" New topic
Author

unble to write the data into file

Narsi Ranch
Greenhorn

Joined: Dec 29, 2010
Posts: 4
Hi ,

i am developing one sample spring web application that is for write the data into test.dat file when i click Register Button.

I wrote the below code for that. But the problem is , data is not writing into file . I thought , that is some configuration problem.

I placed that file in classes folder and WEB-INF folder. So please help me to resolve that problem.



In handle method of RegisterController class::
---------------------------------------------------------


File file = new File("/test.dat");
System.out.println(file.getPath());
try {
fos = new FileOutputStream(file);
FileWriter fw = new FileWriter(file);
fw.write("hello");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
catch(IOException e){
e.printStackTrace();
}
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

And what is the exception that you get?

Also, based on the Servlet Spec, I don't believe you can write to a file in the WEB-INF directory. I am not positive though.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
Consider Paul's rocket mass heater.
 
subject: unble to write the data into file