This week's book giveaway is in the
Agile and other Processes
forum.
We're giving away four copies of
The Mikado Method
and have Ola Ellnestam and Daniel Brolund on-line!
See
this thread
for details.
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Frameworks
»
Spring
Author
unble to write the data into file
Narsi Ranch
Greenhorn
Joined: Dec 29, 2010
Posts: 4
posted
Feb 28, 2011 02:38:36
0
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: 17228
1
I like...
posted
Feb 28, 2011 16:56:45
0
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
I agree. Here's the link:
jrebel
subject: unble to write the data into file
Similar Threads
No unsigned data
Writing to a file from an EJB
Reg PrintWriter
PrintWriter writing not more than 1050000 lines
Writing to a File
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter