tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 
 Java > IO > Get File Path Info

Get File Path Info 

The following example shows how to get the file path related info and file size.

File Name  :  
com/bethecoder/tutorials/io/GetPathInfo.java 
Author  :  Sudhakar KV
Email  :  kvenkatasudhakar@gmail.com
   
package com.bethecoder.tutorials.io;

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

public class GetPathInfo {

  /**
   @param args
   */
  public static void main(String[] argsthrows IOException {
    File file = new File("C:\\NEW\\NEW_SUB\\file_ops.txt");
    
    System.out.println(file);
    System.out.println(file.getAbsolutePath());
    System.out.println(file.getCanonicalPath());
    System.out.println(file.toURL());
    System.out.println(file.toURI());
    
    System.out.println("File Size : " + file.length() " bytes");
  }

}
   

It gives the following output,
C:\NEW\NEW_SUB\file_ops.txt
C:\NEW\NEW_SUB\file_ops.txt
C:\NEW\NEW_SUB\file_ops.txt
file:/C:/NEW/NEW_SUB/file_ops.txt
file:/C:/NEW/NEW_SUB/file_ops.txt
File Size : 12 bytes


                    Print

   



Books Recommendation

 
 
bl  br