| Author |
How to create an un-existed path using stream
|
chaohua wang
Ranch Hand
Joined: Dec 22, 2002
Posts: 62
|
|
Hi folks, currently I can save file to an existed path. like this ------------------------------------------------ String file=D:\\test\\test.txt BufferedInputStream bistr = new BufferedInputStream(conn.getInputStream()); FileOutputStream fostr = new FileOutputStream(file); BufferedOutputStream bostr = new BufferedOutputStream( fostr ); while(-1 != (bytesRead = bistr.read(buff, 0, buff.length))) bostr.write(buff, 0, bytesRead); ---------------------------------------------------------------- currenlty the path D:\\test\\ existes. I tried an an un-existed path, like D:\\test1\\ there is an error message: this path doesn't exist. How can save it to an un-existed path? Thank you. Chaohua
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24081
|
|
|
You have to create the directories first. See the "mkdir" and "mkdirs" methods of java.io.File.
|
[Jess in Action][AskingGoodQuestions]
|
 |
 |
|
|
subject: How to create an un-existed path using stream
|
|
|