Skip to content

Instantly share code, notes, and snippets.

@sujee
Created August 25, 2011 00:10
Show Gist options
  • Save sujee/1169626 to your computer and use it in GitHub Desktop.
Save sujee/1169626 to your computer and use it in GitHub Desktop.
hadoop utilities : StringUtils 1
import org.apache.hadoop.util.StringUtils;
// --- human readable byte lengths -----
System.out.println ("1024 bytes = " + StringUtils.byteDesc(1024));
System.out.println ("67108864 bytes = " + StringUtils.byteDesc(67108864));
System.out.println ("1000000 bytes = " + StringUtils.byteDesc(1000000));
/* produces:
1024 bytes = 1 KB
67108864 bytes = 64 MB
1000000 bytes = 976.56 KB
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment