List of utility methods to do File Size Get
String | countFileDisplaySize(long size) count File Display Size String displaySize; if (size / ONE_GB > 0) { displaySize = format(Math.floor(size * 100.0 / ONE_GB) / 100) + "G"; } else if (size / ONE_MB > 0) { displaySize = format(Math.floor(size * 100.0 / ONE_MB) / 100) + "M"; } else if (size / ONE_KB > 0) { displaySize = format(Math.floor(size * 100.0 / ONE_KB) / 100) + "K"; } else { ... |
String | countFileSize(String pathname) count File Size String fileSizeString = ""; try { File file = new File(pathname); DecimalFormat df = new DecimalFormat("#.00"); long fileS = file.length(); if (fileS < 1024) { fileSizeString = "0byte"; } else if (fileS < 1048576) { ... |
String | fileSizeString(long bytes) file Size String ensureFormat(); final StringBuffer result = new StringBuffer(64); double value; if (bytes >= ONE_GB) { value = scaleToThreeDecimals(bytes, ONE_GB); result.append(format.format(value)); result.append(" GB"); } else if (bytes >= ONE_MB) { ... |
String | getFileKBSize(long fsize) Retrieves the file size with KB format if (fsize < 0) { throw new IllegalArgumentException("File size can't be nagetive."); long size = fsize / 1000; long li = fsize % 1000; if (li > 0) { size++; return NumberFormat.getInstance().format(size) + " KB"; |
long | getFileSize(@Nonnull File file) get File Size if (!file.exists()) { return -1L; long size = 0; if (file.isDirectory()) { File[] files = file.listFiles(); if (files != null && files.length > 0) { for (File f : files) { ... |
long | getFileSize(File dir) Get size of the file long size = 0; if (dir.isFile()) { size = dir.length(); } else { File[] subFiles = dir.listFiles(); for (File file : subFiles) { if (file.isFile()) { size += file.length(); ... |
String | getFileSize(File element) get File Size if (element.isDirectory()) { return ""; } else { long filesizeInKb = ((element.length() + 512) / 1024); return "" + numberFormat.format(filesizeInKb) + " KB"; |
long | getFileSize(File f) get File Size long s = 0; if (f.exists()) { FileInputStream fis = null; try { fis = new FileInputStream(f); s = fis.available(); } catch (Exception e) { e.printStackTrace(); ... |
String | getFileSize(File file) get File Size String size; long bytes = file.length(); if (bytes == 0) { size = ""; } else if (bytes < 1024) { size = bytes + "b"; } else { float kb = bytes / 1024F; ... |
long | getFileSize(File file) get File Size return file.length();
|