No, there's no performance advantage to using FileInputStream
over a URLConnection
(well, unless you're counting the milliseconds of a handful of extra method calls).
Reading a file via a file://
URL eventually gets you a FileURLConnection
(note that this is not part of the official Java library spec, just the Sun-based JREs). If you look at the code, you'll see that it's creating a FileInputStream
to work with the file on disk. So other than walking a few layers further down in the stack, the code ends up exactly the same.
The reason why you'd want to use a FileInputStream
directly is for clarity of your code. Turning a file path into a URL is a little ugly, and it'd be confusing to do it if you were only ever going to work with files.
In your case, where you need to work with URLs some of the time, it's quite convenient that you can use a file URL and only work with URLs. I imagine you've abstracted nearly all of the interesting logic to work on URLs and can do the ugly business of constructing a file or non-file URL elsewhere.