InputStream from a URL
Solution 1:
Use java.net.URL#openStream()
with a proper URL (including the protocol!). E.g.
InputStream input = new URL("http://www.somewebsite.com/a.txt").openStream();
// ...
See also:
- Using java.net.URLConnection to fire and handle HTTP requests
Solution 2:
Try:
final InputStream is = new URL("http://wwww.somewebsite.com/a.txt").openStream();
Solution 3:
(a) wwww.somewebsite.com/a.txt
isn't a 'file URL'. It isn't a URL at all. If you put http://
on the front of it it would be an HTTP URL, which is clearly what you intend here.
(b) FileInputStream
is for files, not URLs.
(c) The way to get an input stream from any URL is via URL.openStream(),
or URL.getConnection().getInputStream(),
which is equivalent but you might have other reasons to get the URLConnection
and play with it first.