I was trying to build the program which tells me the exact size of that file, but i was not getting it. Example: if i give the path of the image file of 64kb, it should return me the value 64kb. Can anyone provide me the code here please???
I was trying to build the program which tells me the exact size of that file, but i was not getting it. Example: if i give the path of the image file of 64kb, it should return me the value 64kb. Can anyone provide me the code here please???
to get the size of a file :
Hope this Helps!Code:File file = new File("infilename"); long length = file.length();
Read The Docs there is a method on it! To read Doc follow the link below :
DOCUMENT
I have written the following code. Just run it & give the Path of the file in the input box it will give you the output in kb.
Code:import java.io.; import javax.swing.; public class FileSizeTest { public static void main(String args[]) { String file = JOptionPane.showInputDialog("File Path and Name, please type like C:\\directoyname\\filename"); File f=new File(file); long size=f.length()/1000; System.out.println(size"KB"); } }
Bookmarks