I am studying for the Java 1.8 OCP exam and I ran across something in the Oracle study guide p.459 where it says you can load a remote URL as a FileSystem object. I tried this and can't get it to work. What is the simplest hello-world style answer to get this working?
import java.net.*;
import java.nio.file.*;
public class FileTest {
public static void main(String[] args) throws URISyntaxException, MalformedURLException {
FileSystem remoteFS = FileSystems.getFileSystem(
new URI("http://www.gutenberg.org/files/55007")
);
Path remotePath = remoteFS.getPath("55007-0.txt");
System.out.println(remotePath.isAbsolute());
}
}
It throws the error:
Exception in thread "main" java.nio.file.ProviderNotFoundException:
Provider "http" not found
at java.nio.file.FileSystems.getFileSystem(FileSystems.java:224)
at qa.test.FileTest.main(FileTest.java:7)
Addendum: FileSystemProvider.installedProviders() returns
[sun.nio.fs.MacOSXFileSystemProvider@4554617c, com.sun.nio.zipfs.ZipFileSystemProvider@74a14482]