List of usage examples for org.apache.commons.io FileUtils byteCountToDisplaySize
public static String byteCountToDisplaySize(long size)
From source file:com.discursive.jccook.io.FileDeleteExample.java
public void start() { File file = new File("project.xml"); String display = FileUtils.byteCountToDisplaySize(file.length()); System.out.println("project.xml is " + display); System.out.println("Byte in KB: " + FileUtils.ONE_GB); display = FileUtils.byteCountToDisplaySize(12073741824l); System.out.println("size: " + display); }
From source file:com.splunk.shuttl.server.mbeans.rest.RestUtil.java
/** * @return JSON response with buckets and their total size. *//*from w w w. j ava2 s. co m*/ public static String respondWithBuckets(List<Bucket> buckets) { List<BucketBean> beans = new ArrayList<BucketBean>(); long totalBucketsSize = 0; for (Bucket bucket : buckets) { beans.add(getBucketBean(bucket)); totalBucketsSize += bucket.getSize() == null ? 0 : bucket.getSize(); } Map<String, Object> response = new HashMap<String, Object>(); response.put("buckets_TOTAL_SIZE", FileUtils.byteCountToDisplaySize(totalBucketsSize)); response.put("buckets", beans); return RestUtil.writeMapAsJson(response); }
From source file:jease.cmf.web.node.NodeViews.java
public static View<String> asSize(Node node) { if (node.isContainer()) { long items = node.getChildren().length; String text = String.format(" %s %s", items, items == 1 ? I18N.get("Item") : I18N.get("Items")); return new View<String>(text, new Label(text)); } else {// ww w. j av a2 s . c o m long size = node.getSize(); String text = FileUtils.byteCountToDisplaySize(size); return new View<String>(String.valueOf(size), new Label(text)); } }
From source file:jease.cms.service.Informations.java
public String getDatabaseSize() { return FileUtils.byteCountToDisplaySize(FileUtils.sizeOfDirectory(new File(getDatabaseDirectory()))); }
From source file:com.hp.alm.ali.idea.model.type.FileSizeType.java
@Override public String translate(String value, ValueCallback callback) { return FileUtils.byteCountToDisplaySize(Long.valueOf(value)); }
From source file:com.mothsoft.alexis.web.faces.HumanReadableBytesConverter.java
public String getAsString(FacesContext context, UIComponent component, Object object) throws ConverterException { final Integer value = (Integer) object; return FileUtils.byteCountToDisplaySize(value); }
From source file:it.anyplace.sync.core.beans.FolderStats.java
public String describeSize() { return FileUtils.byteCountToDisplaySize(getSize()); }
From source file:com.talis.entity.TestUtils.java
public static void showMemory() { Runtime r = Runtime.getRuntime(); long bytes = r.totalMemory() - r.freeMemory(); System.out.println(String.format("Memory usage : %s (%s)", FileUtils.byteCountToDisplaySize(bytes), bytes)); }
From source file:com.santiagolizardo.madcommander.components.filelisting.model.FileListingRow.java
public String getSize() { if (file.isDirectory()) { return ""; }/*from w w w.j a v a 2s . c o m*/ if (SHOW_BYTES) { return FileUtils.byteCountToDisplaySize(file.length()); } else { return FormatSingleton.getSimpleDecimalFormat().format(file.length()); } }
From source file:fr.inria.atlanmod.neoemf.benchmarks.query.Query.java
default V callWithMemoryUsage() throws Exception { V result;//from w ww. j a v a2s . c om Runtime runtime = Runtime.getRuntime(); runtime.gc(); long initialUsedMemory = runtime.totalMemory() - runtime.freeMemory(); log.info("Used memory before call: {}", FileUtils.byteCountToDisplaySize(initialUsedMemory)); result = callWithTime(); runtime.gc(); long finalUsedMemory = runtime.totalMemory() - runtime.freeMemory(); log.info("Used memory after call: {}", FileUtils.byteCountToDisplaySize(finalUsedMemory)); log.info("Memory use increase: {}", FileUtils.byteCountToDisplaySize(finalUsedMemory - initialUsedMemory)); return result; }