i am using the command long filesize = file.length() but this is returning the wrong value. it is saying there are 0 bytes in a folder that has at least 4 GB in?
//File length
int size = (int)file.length();
if (size > Integer.MAX_VALUE){
System.out.println("File is to larger");
}
The size check is redundant. By casting the file size as an int, its value will never exceed Integer.MAX_VALUE, because an overflow will occur on the first line. You should declare size as long and not cast length()
GoodDuy Phong Nguyen November 3, 2011 at 1:27 PM
I have problem about this. And when I read this topic, my problem has been resolved Thank you so much !!!
lonf filesizeJon January 23, 2012 at 4:45 AM
i am using the command long filesize = file.length() but this is returning the wrong value. it is saying there are 0 bytes in a folder that has at least 4 GB in?
Error in codeBrian S. August 1, 2012 at 1:57 AM
//File length int size = (int)file.length(); if (size > Integer.MAX_VALUE){ System.out.println("File is to larger"); } The size check is redundant. By casting the file size as an int, its value will never exceed Integer.MAX_VALUE, because an overflow will occur on the first line. You should declare size as long and not cast length()
Post your Comment