0

有人可以告诉我我的代码有什么问题吗?当我尝试将文件加载到fileInputStream

错误信息:

java.io.FileNotFoundException: file:\C:\Users\zzxx\Desktop\netBean\hw3\Sokoban_draft\data\1.sok (The filename, directory name, or volume label syntax is incorrect)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:138)

代码:

String filePath = new String("file:///C:/Users/zzxx/Desktop/netBeanhw3/Sokoban_draft/data/1.sok");

GridRenderer gamePane = new GridRenderer();

File sokFile = new File(filePath);

byte[] bytes = new byte[Long.valueOf(sokFile.length()).intValue()];
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
FileInputStream fis = new FileInputStream(sokFile);
BufferedInputStream bis = new BufferedInputStream(fis);
4

1 回答 1

0

您不需要指定文件协议。(文件:///)

只需使用路径名即可。

于 2014-10-08T08:17:33.590 回答