List of usage examples for org.apache.commons.io FileUtils byteCountToDisplaySize
public static String byteCountToDisplaySize(long size)
From source file:eionet.gdem.conversion.spreadsheet.SourceReaderLogger.java
/** * End reading spreadsheet.//from w w w . j av a2s . c o m * @param fileSize File size */ public void logEndWorkbook(long fileSize) { BigDecimal totalTime = new BigDecimal(System.currentTimeMillis() - startTimestamp) .divide(new BigDecimal("1000.0")); String fileSizeMessage = ""; if (fileSize > 0) { fileSizeMessage = FileUtils.byteCountToDisplaySize(fileSize); } String message = Properties.getMessage(BusinessConstants.CONVERSION_LOG_END_SPREADSHEET, new String[] { fileSizeMessage, totalTime.toPlainString() }); conversionResult.addConversionLog(ConversionLogType.INFO, message, ConversionLogDto.CATEGORY_WORKBOOK); LOGGER.info(message); }
From source file:com.github.blindpirate.gogradle.util.IOUtils.java
public static String byteCountToDisplaySize(long size) { return FileUtils.byteCountToDisplaySize(size); }
From source file:com.splicemachine.compactions.SpliceDefaultCompactor.java
private String getJobDetails(CompactionRequest request) { if (jobDetails == null) { String delim = ",\n"; jobDetails = getTableInfoLabel(delim) + delim + String.format("Region Name=%s", this.store.getRegionInfo().getRegionNameAsString()) + delim + String.format("Region Id=%d", this.store.getRegionInfo().getRegionId()) + delim + String.format("File Count=%d", request.getFiles().size()) + delim + String.format("Total File Size=%s", FileUtils.byteCountToDisplaySize(request.getSize())) + delim + String.format("Type=%s", getMajorMinorLabel(request)); }// w w w . ja v a 2s.co m return jobDetails; }
From source file:de.interactive_instruments.etf.testrunner.basex.BasexDbPartitioner.java
/** * Creates all databases.//from ww w . j a v a 2 s.co m * * @throws IOException I/O error in visitor method * @throws InterruptedException thread is interrupted */ public void createDatabases() throws IOException, InterruptedException { final long maxChunkSize = getMaxChunkSize(); // Create databases FileVisitor<Path> basexPartitioner = new BasexFileVisitorPartitioner(maxChunkSize); Files.walkFileTree(dbDir, EnumSet.of(FileVisitOption.FOLLOW_LINKS), MAX_DIR_DEPTH, basexPartitioner); if (Thread.currentThread().isInterrupted()) { throw new InterruptedException(); } logger.info("Added " + fileCount + " files (" + FileUtils.byteCountToDisplaySize(size) + ") to " + getDbCount() + " database(s) "); logger.info("Optimizing database " + dbBaseName + "-0"); flushAndOptimize(ctx); new Open(dbBaseName + "-0").execute(ctx); new Close().execute(ctx); ctx.close(); logger.info("Import completed"); }
From source file:com.loop81.fxcomparer.FXComparerController.java
private void handleFile(ComparableArchive archive, TextField filePath, Label infoLabel) { if (archive != null) { filePath.setText(archive.getPath()); infoLabel.setText(MessageBundle.getString("file.info", FileUtils.byteCountToDisplaySize(archive.getSize()), archive.getSize())); if (archive1 != null && archive2 != null) { initCompare();// w ww . j a v a2s. com } } }
From source file:com.adobe.acs.commons.httpcache.store.mem.impl.MemHttpCacheStoreImpl.java
@Override @SuppressWarnings("squid:S1192") protected void addCacheData(Map<String, Object> data, MemCachePersistenceObject cacheObj) { int hitCount = cacheObj.getHitCount(); long size = cacheObj.getBytes().length; data.put(JMX_PN_STATUS, cacheObj.getStatus()); data.put(JMX_PN_SIZE, FileUtils.byteCountToDisplaySize(size)); data.put(JMX_PN_CONTENTTYPE, cacheObj.getContentType()); data.put(JMX_PN_CHARENCODING, cacheObj.getCharEncoding()); data.put(JMX_PN_HITS, hitCount); data.put(JMX_PN_TOTALSIZESERVED, FileUtils.byteCountToDisplaySize(hitCount * size)); }
From source file:de.interactive_instruments.etf.testrunner.basex.BasexTestRunTask.java
/** * Create test databases./*w ww . ja v a 2 s . c o m*/ * <p> * Returns a concatenated error string about non well-formed files * </p> * * @param partitioner BaseX database partitioner * @return skipped non well formed files * @throws IOException I/O error * @throws InterruptedException interrupted by user */ private String createDatabases(final BasexDbPartitioner partitioner) throws IOException, InterruptedException { partitioner.dryRun(); logInfo(partitioner.getFileCount() + " files (" + FileUtils.byteCountToDisplaySize(partitioner.getSize()) + ")" + " will be added to " + partitioner.getDbCount() + " test database(s)"); getBsxTaskProgress().advance(); if (partitioner.getDbCount() > 1) { logInfo("This might take a while..."); } partitioner.reset(); logInfo("Creating a new test database " + partitioner.getFileCount()); partitioner.createDatabases(); logInfo("Added " + partitioner.getFileCount() + " files"); if (!partitioner.getSkippedFiles().isEmpty()) { final StringBuilder skippedFiles = new StringBuilder(); skippedFiles.append( "Skipped " + partitioner.getSkippedFiles().size() + " not well formed file(s): " + SUtils.ENDL); for (String s : partitioner.getSkippedFiles()) { skippedFiles.append(s + SUtils.ENDL); } logInfo(skippedFiles.toString()); return skippedFiles.toString(); } // all files imported return ""; }
From source file:de.burlov.amazon.s3.dirsync.DirSync.java
/** * Synchronisiert Daten im lokalen Verzeichnis und auf dem Server * //from ww w.j a va 2s. c om * @param baseDir * @param folderName * @param up * Synchronisationsrichtung. Wenn 'true' dann werden Daten von lokalen Verzeichnis auf * den Server geschrieben. Wenn 'false' Dann werden Daten von Server auf lokalen * Verzeichnis geschrieben * @param snapShot * Wenn 'true' dann wird Synchronisierung in 'Abbild' Modus duchgefuehrt. D.h. * Zielverzeichnis wird auf den gleichen Stand wie Quelle gebracht: neue Dateien werde * geloescht, geloeschte wiederherstellt und modifiezierte upgedated. Wenn 'false' dann * werden neue Dateien hinzugefuegt und modifizierte upgedated aber auf keinen Fall * irgendetwas geloescht. * @throws DirSyncException */ public void syncFolder(File baseDir, String folderName, boolean up, boolean snapShot) throws DirSyncException { connect(up); deletedFiles = 0; transferredFiles = 0; transferredData = 0; if (!baseDir.isDirectory()) { throw new DirSyncException("Invalid directory: " + baseDir.getAbsolutePath()); } Folder folder = getFolder(folderName); if (folder == null) { if (!up) { log.warn("No such folder " + folderName); //System.out.println("No such folder " + folderName); return; } folder = new Folder(folderName, Long.toHexString(mainIndex.getNextId())); } Collection<LocalFile> files; try { files = generateChangedFileList(baseDir, folder); } catch (Exception e) { throw new DirSyncException(e); } if (up) { syncUp(folder, files, snapShot); } else { syncDown(folder, baseDir, files, snapShot); } log.info("Transferred data: " + FileUtils.byteCountToDisplaySize(transferredData)); log.info("Transferred files: " + transferredFiles); log.info("Deleted/Removed files: " + deletedFiles); }
From source file:de.fme.topx.component.TopXSearchComponent.java
/** * reads the mimetype and content size.// w w w . j a v a2 s. c o m * * @param nodeRef * @param newNode */ private void setContentAttributes(NodeRef nodeRef, Node newNode) { // avoid triggering counting behaviourFilter.disableBehaviour(DataModel.TOPX_ASPECTNAME); ContentReader reader = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT); newNode.setContentSizeFormatted(FileUtils.byteCountToDisplaySize(reader.getSize())); String contentMimetype = reader.getMimetype(); String displayMimetype = displayNamesByMimetype.get(contentMimetype); if (StringUtils.isNotBlank(displayMimetype)) { contentMimetype = displayMimetype; } newNode.setContentMimetype(contentMimetype); behaviourFilter.enableBehaviour(DataModel.TOPX_ASPECTNAME); }
From source file:com.loop81.fxcomparer.FXComparerController.java
/** * Run the compare by embedding the call to {@link Comparer#compare(ComparableArchive, ComparableArchive)} into * a {@link Task} since the operation might take some time depending on the client machine and the archives size * and we do not like to hang the UI-thread. */// w w w . j a v a2 s .co m private void initCompare() { new Thread(new Task<ComparisonResult>() { @Override protected ComparisonResult call() throws Exception { return comparer.compare(archive1, archive2); } @Override protected void succeeded() { ComparisonResult result = getValue(); if (result.isSame()) { labelCompareResult.setText(MessageBundle.getString("result.same")); } else { long diff = archive2.getSize() - archive1.getSize(); labelCompareResult.setText(MessageBundle.getString("result.different", FileUtils.byteCountToDisplaySize(archive1.getSize()), FileUtils.byteCountToDisplaySize(archive2.getSize()), convertdifferenceToReadableString(diff))); } compareTable.setItems(FXCollections.observableList(result.getEntries())); } @Override protected void failed() { new AlertDialog(MessageBundle.getString("exceptions.archive.compare")).show(); getException().printStackTrace(); } }).start(); }