Java IO Tutorial - Java File.toPath()








Syntax

File.toPath() has the following syntax.

public Path toPath()

Example

In the following code shows how to use File.toPath() method.

//from ww  w . j  a  va2 s.c o m
import java.io.File;

public class Main {

  public static void main(String[] args) {
    File file = new File("c:/a.htm");
    System.out.println(file.toPath());
  }
}

The code above generates the following result.