Sample Programs

Sample java program to get absolute path of the file

 package org.jusfortechies.example; 

 import java.io.File;
 
 public class GetAbsolutePathOfFile {

   public static void main(String[] args) {
      
      // Create an instance of File
      File file = new File("samplefile.txt");

      // Get the absolute path of the file
      String absolutePath = file.getAbsolutePath();

      System.out.println("File absolute path = " + absolutePath);
      
   }

 }




blog comments powered by Disqus