List of usage examples for org.apache.commons.io FileUtils byteCountToDisplaySize
public static String byteCountToDisplaySize(long size)
From source file:com.tasktop.c2c.server.configuration.service.FileSystemMetricCollector.java
@Override public void collect(ProjectServiceStatus status) { String actualPath = path.replace(PROJECT_ID_VAR, status.getProjectIdentifier()); File directory = new File(actualPath); if (!directory.exists()) { status.setServiceState(ServiceState.UNAVAILABLE); return;/* w w w . j av a 2s . co m*/ } if (!directory.isDirectory()) { status.setServiceState(ServiceState.UNAVAILABLE); return; } long totalByteSize; try { totalByteSize = com.tasktop.c2c.server.configuration.service.FileUtils.size(directory); status.setServiceState(ServiceState.RUNNING); status.getMetrics().put(ProjectServiceStatus.DISK_USAGE_METRICS_KEY, totalByteSize + ""); status.getMetrics().put(ProjectServiceStatus.DISK_USAGE_HR_METRICS_KEY, FileUtils.byteCountToDisplaySize(totalByteSize)); } catch (IOException e) { e.printStackTrace(); } }
From source file:gov.nih.nci.caarray.application.arraydesign.ArrayDesignMemoryTest.java
@Test public void testLoadDesign() { fusionCDFData.setFileName(AffymetrixArrayDesignFiles.TEN_K_CDF.getAbsolutePath()); fusionCDFData.read();// w w w. ja v a 2s .c o m int numProbeSets = fusionCDFData.getHeader().getNumProbeSets(); FusionCDFProbeSetInformation probeSetInformation = new FusionCDFProbeSetInformation(); for (int index = 0; index < numProbeSets; index++) { fusionCDFData.getProbeSetInformation(index, probeSetInformation); handleProbeSet(probeSetInformation, fusionCDFData.getProbeSetName(index)); } fusionCDFData.clear(); fusionCDFData = null; probeSetInformation.clear(); probeSetInformation = null; System.gc(); System.out.println("Feature count = " + details.getFeatures().size()); long memSize = Runtime.getRuntime().totalMemory(); System.out.println("Mem size = " + memSize); System.out.println("Mem size (formatted) = " + FileUtils.byteCountToDisplaySize(memSize)); System.out.println("Bytes per Feature = " + memSize / details.getFeatures().size()); }
From source file:edu.hm.cs.fs.scriptinat0r7.model.ScriptDocument.java
public String getFileSizeFormatted() { return FileUtils.byteCountToDisplaySize(fileSize); }
From source file:com.splunk.shuttl.server.model.BucketBean.java
/** * @param bucket/*ww w . j a v a2 s. com*/ * to create bean from. */ public static BucketBean createBeanFromBucket(Bucket bucket) { String size = FileUtils.byteCountToDisplaySize(bucket.getSize() == null ? 0 : bucket.getSize()); return new BucketBean(bucket.getFormat().name(), bucket.getIndex(), bucket.getName(), bucket.getURI().toString(), stringFromDate(bucket.getEarliest()), stringFromDate(bucket.getLatest()), size); }
From source file:com.opentangerine.clean.Summary.java
/** * Add file to summary.//from w w w. j a v a 2 s. com * * @param file File to add. */ public void add(final File file) { this.count += 1; this.total += FileUtils.sizeOf(file); Logger.info(Clean.class, String.format("%s %s: %s [%s]", Summary.info(this.mode.readonly(), "Found", "Deleting"), Summary.info(file.isDirectory(), "directory", "file"), file, FileUtils.byteCountToDisplaySize(FileUtils.sizeOf(file)))); }
From source file:com.willkara.zeteo.reporters.impl.FileDirectoryReport.java
/** * Print out to the terminal/*from w w w .j ava2 s. c o m*/ */ @Override public void exportToTerminal() { System.out.println(name + "\n\n"); System.out.println("File Type: Number of Files , Size of Files"); System.out.println("-------------------------------------------"); for (Map.Entry<String, List<BaseFileType>> e : ex.getFileCounter().entrySet()) { String ext = e.getKey(); System.out.printf("%s: %d, %s\n", ext, ex.getCountOfFilesForExtension(ext), FileUtils.byteCountToDisplaySize(ex.getFileTypeTotalSize(ext))); } System.out.println("-------------------------------------------"); System.out.println("Most common file type: " + ex.getMostCommonFileType()); System.out.println("-------------------------------------------"); System.out.println("Total count of files: " + ex.getTotalFileCount()); System.out.println("Total size of files: " + FileUtils.byteCountToDisplaySize(ex.getTotalSizeCount())); }
From source file:de.elomagic.mag.ServletMock.java
@Override protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { received = false;//from w w w. j av a 2 s. c o m lastContentLength = request.getContentLength(); requestedUri = request.getRequestURI(); if (lastContentLength > 0) { lastContent = IOUtils.readFully(request.getInputStream(), lastContentLength); } LOGGER.info("contentLength=" + FileUtils.byteCountToDisplaySize(lastContentLength)); LOGGER.info("content" + lastContent); response.setStatus(HttpServletResponse.SC_CREATED); received = true; }
From source file:gov.nih.nci.cabig.caaers.domain.AdditionalInformationDocument.java
@Transient public String getByteCountToDisplaySize() { return FileUtils.byteCountToDisplaySize(fileSize); }
From source file:com.thoughtworks.go.server.service.support.garage.GarageService.java
String getDirectorySize(File configRepoDir) {
return FileUtils.byteCountToDisplaySize(FileUtils.sizeOfDirectory(configRepoDir));
}
From source file:it.anyplace.sync.core.cache.FileBlockCache.java
private void runCleanup() { if (size > MAX_SIZE) { logger.info("starting cleanup of cache directory, initial size = {}", FileUtils.byteCountToDisplaySize(size)); List<File> files = Lists.newArrayList(dir.listFiles()); Collections.sort(files, Ordering.natural().onResultOf(new Function<File, Long>() { @Override//from ww w .ja v a 2s . c om public Long apply(File input) { return input.lastModified(); } })); for (File file : Iterables.limit(files, (int) (files.size() * PERC_TO_DELETE))) { logger.debug("delete file {}", file); FileUtils.deleteQuietly(file); } size = FileUtils.sizeOfDirectory(dir); logger.info("cleanup of cache directory completed, final size = {}", FileUtils.byteCountToDisplaySize(size)); } }