Powered by Ajaxy
Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Java: How to get File size in bytes , Kilobyte and megabyte

Java: How to get File size in bytes , Kilobyte and megabyte
{filelink=7946}

import java.io.File;
public class Taille_Fichier
 {
  public static void main(String[] args)
  {
    File fichier = new File("D:/file.txt");
    long taille = fichier.length();
    // size in  bytes
    System.out.println(taille + " octets");    
    // size in  Kilobyte
    System.out.println((double) taille / 1024 + " KB");
    // size in  megabyte
    System.out.println((double) taille / (1024 * 1024) + "MB");
  }
}

Users who found this page were searching for:

  • python change values in dictionary
  • java percent class

No comments yet.

Leave a Comment