Java File.toString()

Syntax

File.toString() has the following syntax.

public String toString()

Example

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


//from  w  w w  .j a va2 s .co  m

import java.io.File;

public class Main {
  public static void main(String[] args) {
    File f = new File("test.txt");

    String str = f.toString();

    System.out.println("pathname string: " + str);

  }
}

The code above generates the following result.