I’m trying to open a zip file with jython using FileInputStream and ZipInputStream. But I’m strangely getting an FileNotFoundException when FileInputStream is called.
Here is my code:
from java.lang import System
from java.io import ObjectInputStream, FileInputStream, BufferedInputStream
from java.util.zip import ZipInputStream, ZipEntry
file_input_stream = FileInputStream('C:\\Documents and Settings\\usr\\My Documents\\Downloads\\test.zip')
zip_input_stream = ZipInputStream(BufferedInputStream(file_input_stream))
entry = zip_input_stream.getNextEntry()
entry = zip_input_stream.getNextEntry()
object_input_stream = ObjectInputStream(zip_input_stream)
graph.model = object_input_stream.readObject()
object_input_stream.close()
zip_input_stream.close()
file_input_stream.close()
My error is :
file_input_stream = FileInputStream('C:\\Documents and Settings\\usr\\My Documents\\Downloads\\test.zip')
Traceback (most recent call last):
File "<input>", line 1, in <module>
FileNotFoundException: java.io.FileNotFoundException: C:\Documents and Settings\usr\My Documents\Downloads\test.zip (The system cannot find the file specified)
I know for sure that the file is in the correct directory, if I call FileInputStream with a non-zip file, it works. What am I doing wrong here?
thanks
Open any folder in windows explorer. If you’re using windows 7 or Vista, press alt to view the menu bar (on XP it should already be visible). Pick Tools -> Folder Options. In the view tab, search in the box for a checkbox labeled “Hide extensions for known file types” and uncheck it.
On that note, the file is probably called “test.zip.zip”, which would be why “test.zip” is not found.