1 package org.apache.turbine.util; 2 3 18 19 27 public class FileUtils 28 { 29 32 public static final int ONE_KB = 1024; 33 34 37 public static final int ONE_MB = ONE_KB * ONE_KB; 38 39 42 public static final int ONE_GB = ONE_KB * ONE_MB; 43 44 51 public static String byteCountToDisplaySize(int size) 52 { 53 String displaySize; 54 55 if (size / ONE_GB > 0) 56 { 57 displaySize = String.valueOf(size / ONE_GB) + " GB"; 58 } 59 else if (size / ONE_MB > 0) 60 { 61 displaySize = String.valueOf(size / ONE_MB) + " MB"; 62 } 63 else if (size / ONE_KB > 0) 64 { 65 displaySize = String.valueOf(size / ONE_KB) + " kB"; 66 } 67 else 68 { 69 displaySize = String.valueOf(size) + " bytes"; 70 } 71 72 return displaySize; 73 } 74 } 75 | Popular Tags |