Java IO Tutorial - Java File(File parent, String child) Constructor








Syntax

File(File parent, String child) constructor from File has the following syntax.

public File(File parent,  String child)

Example

In the following code shows how to use File.File(File parent, String child) constructor.

import java.io.File;
// w  w  w .  j  a  v a  2 s .co m
public class Main {

  public static void main(String[] args) {

    File parent = new File("c:/aFolder");
    File aFile = new File(parent, "aFile.txt");
    
    System.out.println(aFile);//c:\aFolder\aFile.txt

  }
}

The code above generates the following result.