Java I/O How to - Create a file from a URI for a remote file








Question

We would like to know how to create a file from a URI for a remote file.

Answer

//from w  w w  .  jav a2 s  . c om
import java.io.File;
import java.net.URI;

public class Main {
  public static void main(String[] a) throws Exception {

    File remoteFile = new File(new URI("file:///index.htm"));
    System.out.println(remoteFile);
  }
}

The code above generates the following result.