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