我想用jython使用FileInputStream和ZipInputStream打開zip文件。但是當我調用FileInputStream時,我很奇怪地得到了FileNotFoundException。jython打開zip文件並閱讀其內容
這裏是我的代碼:
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()
我的錯誤是:
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)
我知道肯定該文件是在正確的目錄,如果我叫的FileInputStream與非壓縮文件, 有用。我在這裏做錯了什麼?
感謝
這不是因爲沒有顯示文件擴展名造成的問題,是嗎?你是否在瀏覽器中顯示文件擴展名? – Wug
@Wug我可以看到這個zip文件的擴展名正確,但並不是所有的文件在瀏覽器中的文件擴展名都可見。 – mugetsu