Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

fileNotFoundException but file exists

Writer Olivia Zamora

in my FileInputStream I get a FileNotFoundException, but I know he file exists, I can download it with the webbrowser.

It also works if I copy the Link from the exception to webbrowser. Rights are on RWX to everyone for testing, but this doesn't help.

there are no special signs in the filename... I have no idea why this fails..

thx 4 help!

EDIT:

KeyStore ts = KeyStore.getInstance("PKCS12");
ts.load(new FileInputStream(""), passwKey);
KeyManagerFactory tmf = KeyManagerFactory.getInstance("SunX509");
tmf.init(ts, passwKey);

I changed the link for security reasons

3

4 Answers

You should use

InputStream is = new URL("").openStream();

instead of a FileInputStream.

0

See exception message... probably you don't have permission "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? 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.

Maybe you'd rather use URL.openStream() which would work on any kind of URL, including remote ones.

From Java specification:

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?

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.