Get file size in Java



This piece of code gets the size of a file in bytes. It’s done by creating a File object and checks that it actually exists and is a file and not a directory. Then we call the length() method which will return the size in bytes.







Search for more Java info on this site here:
Custom Search


Please type any questions here.