I have a bunch of file sizes that I would like to parse. These are currently only in GBs. Here are some samples:
- 1.2GB
- 2.4GB
I think I should store my byte filesizes in a Long
value but I can't seem to figure it out. Here's how I'm doing it:
System.out.println(Float.parseFloat("1.2GB".replace("GB", ""))* 1024L * 1024L * 1024L);
This returns a Float
value which is displayed as 1.28849024E9
. How can I get a Long
representation of the filesize in bytes.
I've gotten a little confused with the numeric datatypes. Thanks.