1 // Copyright 2000-2006 the Contributors, as shown in the revision logs.
2 // Licensed under the Apache Public Source License 2.0 ("the License").
3 // You may not use this file except in compliance with the License.
7 /** prints numbers (like 1000) as byte sizes (like 1mb) */
8 public class ByteSize {
10 public static String toString(int bytes) {
15 if (bytes < 1024 * 1024)
16 return (bytes/1024)+"kb";
18 if (bytes < 1024 * 1024 * 1024)
19 return (bytes/(1024*1024))+"mb";
21 if (bytes < 1024 * 1024 * 1024 * 1024)
22 return (bytes/(1024*1024*1024))+"gb";