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

/*w w w  .j ava  2  s  . c  o  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.