Monday, March 14, 2016

Java I/O Examples : How To Get Absolute Path Of The File

Intro


This examples, will demonstrates how to get absolute path of the file. To get an absolute path of the file, you can use File.getAbsolutePath() method.

Examples


package com.freesamplecode.java.io;

import java.io.File;

public class GetAbsolutePathDemo {
 public static void main(String[] args){
  File file = new File("D:/temp/data/aku.txt");
  
  if(file.exists()){
   System.out.println("Absolute Path : "+file.getAbsolutePath());
   System.out.println("Path : "+file.getPath());
  }
 }
}


Screenshot

How To Get Absolute Path Of The File


0 comments: