package file_space;
import java.io.*;
public class file_size {
public long file_size_bytes(long file_size)
{
return (long) (file_size);
}
public long file_size_KB(long file_size)
{
return (file_size/1024);
}
public long file_size_MB(long file_size)
{
return (file_size/1024/1024);
}
public long file_size_GB(long file_size)
{
return (file_size/1024/1024/1024);
}
public static void sop(Object str)
{
System.out.println("File Size on Drive is "+str);
}
public static void main(String args[])
{
File file=new File("files/file_txt.txt");
//System.out.println(file.exists());
//System.out.println(file.getAbsolutePath());
//Long bytes=file.length();
Long bytes=file.getFreeSpace();
file_size fs=new file_size();
sop(fs.file_size_bytes(bytes)+" Bytes");
sop(fs.file_size_KB(bytes)+" KB");
sop(fs.file_size_MB(bytes)+" MB");
sop(fs.file_size_GB(bytes)+" GB");
}
}
No comments:
Post a Comment
Please add value. Sharing is caring