Does anyone has an idea why this cast is not good:
URI myUri = URI.create("http://storage.googleapis.com/autoplay_audio/titanium.mp3");
File f = new File(myUri);
Does anyone has an idea why this cast is not good:
URI myUri = URI.create("http://storage.googleapis.com/autoplay_audio/titanium.mp3");
File f = new File(myUri);
You cannot use anything other than a file uri (eg file://
).
The constructor File(URI)
has the following condition check:
String scheme = uri.getScheme();
if ((scheme == null) || !scheme.equalsIgnoreCase("file"))
throw new IllegalArgumentException("URI scheme is not \"file\"");
If you intend to connect to an http
uri, you'll need to use some other mechanism, such as URL.
You can use File only for files. For your example to work, File would need to be aware of the HTTP protocol. You should use Apache HttpClient or some other framework depending on your needs and environment.