FileOutputStream fos = new FileOutputStream(TEMP_DIR +
entry.getName());
The exception is:
java.io.FileNotFoundException: C:\data\myusername\Desktop\zipped.txt
(The system cannot find the path specified)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
at java.io.FileOutputStream.<init>(FileOutputStream.java:70)
at hasrd.gui.skin.ThemeLoader.loadTheme(ThemeLoader.java:82)
at hasrd.gui.skin.ThemeLoader.loadTheme(ThemeLoader.java:57)
at hasrd.TestZipInput.main(TestZipInput.java:11)
Can a FileOutputStream create a directory if it does not already
exist? Is there something else I'm doing wrong?
Thanks
Thomas
No, it won't create it. It's your responsibility.
> Is there something else I'm doing wrong?
Yes. You should create File object and pass it as a parameter to the
constructor of FileOutputStream. You can use mkdirs
http://java.sun.com/javase/6/docs/api/java/io/File.html#mkdirs() to
create the directory.
And third thing you're getting wrong. You should really consider reading
documentation;-)
Regards,
Leonard
--
Simplicity is the ultimate sophistication.
-- Leonardo da Vinci
Actually, the issue was not as simple as what you suggested.
The problem is, I'm attempting to unzip a ZIP file. I'm following the
tutorial found here: http://java.sun.com/developer/technicalArticles/Programming/compression/
and it works, except when there is a "path" value associated with the
entry.
This is what's causing the sticking point, and I'm not really sure how
to handle it. I suppose I could parse the file name off the end of
the path (which I get through entry.getName()) and then create the
files using File.mkdirs(), but that seems too roundabout.
Is there something I'm missing at this point? Like I said - it works
when there is no path value associated with the ZIP file.
Thanks
You can't create file in a directory that doesn't exist. It has to be
created before you can create a file in it. File.mkdirs() is simplest
and for most cases best way to do it. And you can use File to parse
abstract paths (eg. to get the name of directory to be created).
> Is there something I'm missing at this point? Like I said - it works
> when there is no path value associated with the ZIP file.
Because, then, you create the file in current directory.