import java.io.File;The execution of this code gives:
public class main
{
public static void main(String[] args)
{
File file =new File("C:\\test.avi");
if(file.exists()){
double bytes = file.length();
double bits = bytes * 8;
double kilobytes = bytes / 1024;
double megabytes = kilobytes / 1024;
double gigabytes = megabytes / 1024;
double terabytes = gigabytes / 1024;
System.out.println("bits: " + bits + "bits");
System.out.println("bytes: " + bytes+ " bytes");
System.out.println("kilobyte: " + kilobytes+ "KB");
System.out.println("megabyte: " + megabytes + "MB");
System.out.println("gigabyte: " + gigabytes + "GB");
System.out.println("terabyte: " + terabytes + "To");
}else{
System.out.println("Non-existent file");
}
}
}
bits: 4.624187392E9 bitsReferences:
bytes: 5.78023424E8 bytes
kilobyte: 564476.0KB
megabyte: 551.24609375MB
gigabyte: 0.5383262634277344GB
terabyte: 5.257092416286469E-4TB
Please disable your ad blocker and refresh the window to use this website.