FileWriter and Path

S

Stefan.Jia

Hello,

i use FileWriter to write content into a file, the fileName contains
path and file name, however, the path (folder) does not exist:

test/test.txt (the folder "test" does not exist yet)

new FileWriter(fileName) throws an exception.

I don't want to create the folders manually, since there are too many
folders to be created.

thanks!

regards,
schuen
 
A

Andrew T.

Hello,
G'day.

i use FileWriter to write content into a file, the fileName contains
path and file name, however, the path (folder) does not exist:

test/test.txt (the folder "test" does not exist yet)

new FileWriter(fileName) throws an exception.

I don't want to create the folders manually, since there are too many
folders to be created.

Uh-huh. ..Let us know how that goes,
and feel free to pop back by if you have
any questions.

As a general tip, I strongly recommend using
the File(File, String) constructor to build deep
(or any) paths. Obviously, an easy way to get
there is to loop through an array of strings
representing the directory names.

This seems to be almost exactly what you
do not want to do.

No worries!

(As an aside, every sentence should start with
an Upper Case letter. Using caps. at the right
places, helps the reader.)

--
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200704/1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top