Anthony Accioly
Anthony Accioly

Reputation: 22461

Getting the size of a big file

Pretty basic stuff but I can't find a way to read the size of a file with several gigabytes. I'm aware of the method File.length. But int max value is 2,147,483,647. Is there a standard API method to read the size of a file with more than 2 gigabytes (maybe something that returns the length in kilobytes, or with Long / BigInteger)? If there isn't, which libraries are used to do that?

Update

People kindly pointed out that I should RTFM. Long max size can fit 8388608 terabytes. :)

Upvotes: 3

Views: 1836

Answers (3)

Chris Dennett
Chris Dennett

Reputation: 22721

I believe that File.length() returns a long? That should be sufficient.

Upvotes: 3

ratchet freak
ratchet freak

Reputation: 48196

File.length() returns a long

Upvotes: 6

QuantumMechanic
QuantumMechanic

Reputation: 13946

According to the File API doc, length() returns long, not int.

Upvotes: 3

Related Questions