This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 17249
    
    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
 
Don't get me started about those stupid light bulbs.
 
subject: unble to write the data into file
 
Similar Threads
Writing to a File
Writing to a file from an EJB
PrintWriter writing not more than 1050000 lines
Reg PrintWriter
No unsigned data