Java File(String pathname) Constructor

Syntax

File(String pathname) constructor from File has the following syntax.

public File(String pathname)

Example

In the following code shows how to use File.File(String pathname) constructor.


/*  ww  w .  j  a v a 2s  .  c o m*/
import java.io.File;

public class Main {

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

  }
}

The code above generates the following result.