Java File get canonical path

Description

Java File get canonical path

import java.io.File;
import java.io.IOException;

public class Main {
  public static void main(String[] args) {
    // Create a File object
    File myFile = new File("Main.java");

    try {//from  w  w  w .  j  a  va  2  s .  c o m
      System.out.println("Canonical Path: " + myFile.getCanonicalPath());
    } catch (IOException e) {
      e.printStackTrace();
    }

  }
}



PreviousNext

Related