Re: FileInputStream returns FileNotFoundException on Apple Mac

From: Chris (
Date: 05/12/04

Date: 12 May 2004 05:13:38 -0700

> I am trying to reference a file on an apple mac from Java. In order
> to find what the URL is supposed to be, I opened it in the Safari web
> browser. The directory as returned was
> file:///Users/networkserver/SmartAV-CMS/
> When I give this as a String reference to FileInputStream in Java, it
> returns a FileNotFoundException, quoting
> "file:/Users/networkserver/SmartAV-CMS/ (No such
> file or directory).
> I would like to know how to reference this file, and also maybe why it
> takes out 2 of the slashes.

FileInputDevice assumes the string argument is a file-path whereas
you're assuming it's an URL. Either pass in just the file-path (i.e.
omit 'file://' from the start) or check out the URL class (you can get
a File object or InputStream from an URL).

Incidentally that's why it strips out the two slashes from the start
of the URL - it automatically removes what are considered as
superfluous separators in the path.

- sarge