I really hope that you put spaces before {s...
–
ZifreJul 15 '09 at 13:05

Which version of Windows are you running on? Actually doesn't matter if you can parse it back with new URL(String).
–
akarnokdJul 15 '09 at 13:10

@kd304 : well it matters if I'm parsing the result with something else than URL(String), which I do.
–
GhiOmJul 15 '09 at 13:16

1

Amusingly, the javadoc for java.net.URL still refers to the original NCSA Mosaic help pages, which unsurprisingly, is a dead link. I think I might file a bug against that....
–
skaffmanJul 15 '09 at 13:24

1

@kd304 : not myself, but some other library.
–
GhiOmJul 15 '09 at 13:38

The scheme and path components are
required, though the path may be empty
(no characters). When authority is
present, the path must either be empty
or begin with a slash ("/") character.
When authority is not present, the
path cannot begin with two slash
characters ("//"). These restrictions
result in five different ABNF rules
for a path (Section 3.3), only one of
which will match any given URI
reference.

So, there you go. Since file URIs have no authority segment, they're forbidden from starting with //.

However, that RFC didn't come around until 2005, and Java references RFC2396, so I don't know why it's following this convention, as file URLs before the new RFC have always had two slashes.

Section 3.2.2 of RFC 3986 clarifies this by noting that the authority may be empty: "If the URI scheme defines a default for host, then that default applies when the host subcomponent is undefined or when the registered name is empty (zero length). For example, the "file" URI scheme is defined so that no authority, an empty host, and "localhost" all mean the end-user's machine, whereas the "http" scheme considers a missing authority or empty host invalid."
–
Ilmari KaronenJan 8 '13 at 12:51

"If the URI scheme defines a default for host, then that default applies when the host subcomponent is undefined or when the registered name is empty (zero length). For example, the "file" URI scheme is defined so that no authority, an empty host, and "localhost" all mean the end-user's machine, whereas the "http" scheme considers a missing authority or empty host invalid."

So the "file" scheme translates file:///path/file to have a context of the end-user's machine even though the authority is an empty host.

As far as using it in a browser is concerned, it doesn't matter. I have typically seen file:///... but one, two or three '/' will all work. This makes me think (without looking at the java documentation) that it would be normal behavior.