Java IO Tutorial - Java File(URI uri) Constructor








Syntax

File(URI uri) constructor from File has the following syntax.

public File(URI uri)

Example

In the following code shows how to use File.File(URI uri) constructor.

/*w  w w. ja v  a2s. c o  m*/
import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;

public class Main {

  public static void main(String[] args) {
    File aFile;
    try {
      aFile = new File(new URI("file:///c:/a.bat"));
      System.out.println(aFile.getName());//false
    } catch (URISyntaxException e) {
      e.printStackTrace();
    }

  }
}

The code above generates the following result.