Java IO Tutorial - 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.

/* w  ww. j  a  v a  2s . c om*/
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.