简体   繁体   English

fileNotFoundException但文件存在

[英]fileNotFoundException but file exists

in my FileInputStream I get a FileNotFoundException, but I know he file exists, I can download it with the webbrowser. 在我的FileInputStream中我得到一个FileNotFoundException,但我知道他的文件存在,我可以用webbrowser下载它。

It also works if I copy the Link from the exception to webbrowser. 如果我将链接从异常复制到webbrowser,它也可以工作。 Rights are on RWX to everyone for testing, but this doesn't help. 对于每个人来说,RWX都有权利进行测试,但这没有用。

there are no special signs in the filename... I have no idea why this fails.. 文件名中没有特殊标志......我不知道为什么会失败..

thx 4 help! thx 4帮助!

EDIT: 编辑:

KeyStore ts = KeyStore.getInstance("PKCS12");
ts.load(new FileInputStream("http://192.168.1.1/ordner/myFile.p12"), passwKey);
KeyManagerFactory tmf = KeyManagerFactory.getInstance("SunX509");
tmf.init(ts, passwKey);

I changed the link for security reasons 出于安全原因,我更改了链接

You should use 你应该用

InputStream is = new URL("http://stackoverflow.com/").openStream();

instead of a FileInputStream . 而不是FileInputStream

See exception message... probably you don't have permission "java.io.FileNotFoundException (Permission Denied)". 请参阅异常消息...可能您没有权限“java.io.FileNotFoundException(Permission Denied)”。 you have to give permission to the user currently running the application. 您必须授予当前运行该应用程序的用户的权限。

Are you giving FileInputStream a URL as a String? 您是否将FileInputStream作为字符串提供给URL? Then you are using this and it states: 然后你正在使用 ,它说:

Creates a FileInputStream by opening a connection to an actual file, the file named by the path name name in the file system. 通过打开与实际文件的连接来创建FileInputStream,该文件由文件系统中的路径名称命名。

Maybe you'd rather use URL.openStream() which would work on any kind of URL, including remote ones. 也许您宁愿使用URL.openStream() ,它可以在任何类型的URL上工作,包括远程URL。

From Java specification: 从Java规范:

Signals that an attempt to open the file denoted by a specified pathname has failed. 

This exception will be thrown by the FileInputStream, FileOutputStream, and RandomAccessFile constructors when a file with the specified pathname does not exist. It will also be thrown by these constructors if the file does exist but for some reason is inaccessible, for example when an attempt is made to open a read-only file for writing.

Are you sure, any of the scenerio mentioned there is not occuring? 你确定,那里提到的任何一个场景都没有发生?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM