List of usage examples for org.apache.commons.io FileUtils byteCountToDisplaySize
public static String byteCountToDisplaySize(long size)
From source file:org.openmicroscopy.shoola.env.data.util.StatusLabel.java
/** * Sets the collection of files to import. * //from ww w. j av a 2s . c o m * @param usedFiles The value to set. */ public void setUsedFiles(String[] usedFiles) { this.usedFiles = usedFiles; if (usedFiles == null) return; for (int i = 0; i < usedFiles.length; i++) { sizeUpload += (new File(usedFiles[i])).length(); } fileSize = FileUtils.byteCountToDisplaySize(sizeUpload); String[] values = fileSize.split(" "); if (values.length > 1) units = values[1]; }
From source file:org.openpnp.machine.reference.camera.TableScannerCamera.java
public String getCacheSizeDescription() { try {/* ww w . j av a 2 s . c o m*/ return FileUtils.byteCountToDisplaySize(FileUtils.sizeOf(cacheDirectory)); } catch (Exception e) { return "Not Initialized"; } }
From source file:org.pdfsam.ui.dashboard.about.AboutDashboardPane.java
@Inject public AboutDashboardPane(Pdfsam pdfsam) { getStyleClass().add("dashboard-container"); VBox left = new VBox(5); addSectionTitle(pdfsam.name(), left); Label copyright = new Label("Copyright 2014 by Andrea Vacondio"); AwesomeDude.setIcon(copyright, AwesomeIcon.COPYRIGHT); left.getChildren().addAll(new Label(String.format("ver. %s", pdfsam.version())), copyright); addHyperlink(null, "http://www.gnu.org/licenses/agpl-3.0.html", "GNU Affero General Public License v3", left);//from ww w. j a v a2 s .c om addHyperlink(AwesomeIcon.HOME, "http://www.pdfsam.org", "www.pdfsam.org", left); addHyperlink(AwesomeIcon.RSS_SQUARE, "http://www.pdfsam.org/feed/", DefaultI18nContext.getInstance().i18n("Subscribe to the official news feed"), left); addSectionTitle(DefaultI18nContext.getInstance().i18n("Environment"), left); Label runtime = new Label(String.format("%s %s", System.getProperty("java.runtime.name"), System.getProperty("java.runtime.version"))); Label fxRuntime = new Label( String.format("JavaFX %s", com.sun.javafx.runtime.VersionInfo.getRuntimeVersion())); Label memory = new Label(DefaultI18nContext.getInstance().i18n("Max memory {0}", FileUtils.byteCountToDisplaySize(Runtime.getRuntime().maxMemory()))); Button copyButton = new Button(DefaultI18nContext.getInstance().i18n("Copy to clipboard")); AwesomeDude.setIcon(copyButton, AwesomeIcon.COPY); copyButton.getStyleClass().addAll(Style.BUTTON.css()); copyButton.setId("copyEnvDetails"); copyButton.setOnAction(a -> { ClipboardContent content = new ClipboardContent(); writeContent(Arrays.asList(pdfsam.name(), pdfsam.version(), runtime.getText(), fxRuntime.getText(), memory.getText())).to(content); Clipboard.getSystemClipboard().setContent(content); }); left.getChildren().addAll(runtime, fxRuntime, memory, copyButton); addSectionTitle(DefaultI18nContext.getInstance().i18n("Thanks to"), left); addHyperlink(null, "http://www.pdfsam.org/thanks_to", DefaultI18nContext.getInstance().i18n("The open source projects making PDFsam possible"), left); VBox right = new VBox(5); addSectionTitle(DefaultI18nContext.getInstance().i18n("Support"), right); addHyperlink(AwesomeIcon.BUG, "http://www.pdfsam.org/issue_tracker", DefaultI18nContext.getInstance().i18n("Bug and feature requests"), right); addHyperlink(AwesomeIcon.QUESTION_CIRCLE, "http://www.pdfsam.org/wiki", "HowTo wiki", right); addHyperlink(AwesomeIcon.YOUTUBE_PLAY, "http://www.pdfsam.org/quickstart_video", DefaultI18nContext.getInstance().i18n("Play the \"get started\" video"), right); addSectionTitle(DefaultI18nContext.getInstance().i18n("Contribute"), right); addHyperlink(AwesomeIcon.GITHUB, "http://www.pdfsam.org/scm", DefaultI18nContext.getInstance().i18n("Fork PDFsam on GitHub"), right); addHyperlink(AwesomeIcon.FLAG_ALT, "http://www.pdfsam.org/translate", DefaultI18nContext.getInstance().i18n("Translate"), right); addHyperlink(AwesomeIcon.DOLLAR, "http://www.pdfsam.org/donate", DefaultI18nContext.getInstance().i18n("Donate"), right); addSectionTitle(DefaultI18nContext.getInstance().i18n("Social"), right); addHyperlink(AwesomeIcon.TWITTER_SQUARE, "http://www.pdfsam.org/twitter", DefaultI18nContext.getInstance().i18n("Follow us on Twitter"), right); addHyperlink(AwesomeIcon.GOOGLE_PLUS_SQUARE, "http://www.pdfsam.org/gplus", DefaultI18nContext.getInstance().i18n("Follow us on Google Plus"), right); addHyperlink(AwesomeIcon.FACEBOOK_SQUARE, "http://www.pdfsam.org/facebook", DefaultI18nContext.getInstance().i18n("Like us on Facebook"), right); getChildren().addAll(left, right); }
From source file:org.pdfsam.ui.dashboard.AboutDashboardPane.java
@PostConstruct void init() {/*from w w w . j av a2 s . co m*/ VBox left = new VBox(5); addSectionTitle(name, left); left.getChildren().addAll(new Label(String.format("ver. %s", version)), new Label("Copyright 2014 by Andrea Vacondio")); addHyperlink(null, "http://www.gnu.org/licenses/agpl-3.0.html", "GNU Affero General Public License v3", left); addHyperlink(AwesomeIcon.HOME, "http://www.pdfsam.org", "www.pdfsam.org", left); addHyperlink(AwesomeIcon.RSS_SQUARE, "http://www.pdfsam.org/feed/", DefaultI18nContext.getInstance().i18n("Subscribe to the official news feed"), left); addSectionTitle(DefaultI18nContext.getInstance().i18n("Environment"), left); left.getChildren().add(new Label(String.format("%s %s", System.getProperty("java.runtime.name"), System.getProperty("java.runtime.version")))); left.getChildren() .add(new Label(String.format("JavaFX %s", com.sun.javafx.runtime.VersionInfo.getRuntimeVersion()))); left.getChildren().add(new Label(DefaultI18nContext.getInstance().i18n("Max memory {0}", FileUtils.byteCountToDisplaySize(Runtime.getRuntime().maxMemory())))); addSectionTitle(DefaultI18nContext.getInstance().i18n("Thanks to"), left); addHyperlink(null, "http://www.pdfsam.org/thanks_to", DefaultI18nContext.getInstance().i18n("The open source projects making PDFsam possible"), left); VBox right = new VBox(5); addSectionTitle(DefaultI18nContext.getInstance().i18n("Support"), right); addHyperlink(AwesomeIcon.BUG, "http://www.pdfsam.org/issue_tracker", DefaultI18nContext.getInstance().i18n("Bug and feature requests"), right); addHyperlink(AwesomeIcon.QUESTION_CIRCLE, "http://www.pdfsam.org/wiki", "HowTo wiki", right); addHyperlink(AwesomeIcon.YOUTUBE_PLAY, "http://www.pdfsam.org/quickstart_video", DefaultI18nContext.getInstance().i18n("Play the \"get started\" video"), right); addSectionTitle(DefaultI18nContext.getInstance().i18n("Contribute"), right); addHyperlink(AwesomeIcon.GITHUB, "http://www.pdfsam.org/scm", DefaultI18nContext.getInstance().i18n("Fork PDFsam on GitHub"), right); addHyperlink(AwesomeIcon.DOLLAR, "http://www.pdfsam.org/donate", DefaultI18nContext.getInstance().i18n("Donate"), right); addSectionTitle(DefaultI18nContext.getInstance().i18n("Social"), right); addHyperlink(AwesomeIcon.TWITTER_SQUARE, "http://www.pdfsam.org/twitter", DefaultI18nContext.getInstance().i18n("Follow us on Twitter"), right); addHyperlink(AwesomeIcon.GOOGLE_PLUS_SQUARE, "http://www.pdfsam.org/gplus", DefaultI18nContext.getInstance().i18n("Follow us on Google Plus"), right); addHyperlink(AwesomeIcon.FACEBOOK_SQUARE, "http://www.pdfsam.org/facebook", DefaultI18nContext.getInstance().i18n("Like us on Facebook"), right); getChildren().addAll(left, right); }
From source file:org.pdfsam.ui.info.SummaryTab.java
private void setFileProperties(File file) { fileLabel.setText(file.getAbsolutePath()); size.setText(FileUtils.byteCountToDisplaySize(file.length())); modified.setText(FORMATTER.format(file.lastModified())); }
From source file:org.pdfsam.ui.info.SummaryTabTest.java
private void assertInfoIsDisplayed(List<ChangeListener<? super String>> listeners, PdfDocumentDescriptor descriptor) { File file = descriptor.getFile(); List<String> values = Arrays.asList("test.producer", file.getAbsolutePath(), descriptor.getVersionString(), "2", "test.creationDate", "test.title", "test.author", "test.creator", "test.subject", FileUtils.byteCountToDisplaySize(file.length()), FORMATTER.format(file.lastModified())); listeners.forEach(l -> verify(l, timeout(2000).times(1)).changed(any(), any(), argThat(isIn(values)))); }
From source file:org.polymap.core.data.image.cache304.Cache304.java
protected Cache304() { try {//from w w w . j a v a 2s .com store = new LuceneRecordStore(new File(Polymap.getCacheDir(), "tiles.index"), false); store.setIndexFieldSelector(new IRecordFieldSelector() { public boolean accept(String key) { return !key.equals(CachedTile.TYPE.data.name()); } }); dataDir = new File(Polymap.getCacheDir(), "tiles.data"); dataDir.mkdirs(); log.info("Data dir: " + dataDir + " - Checking size..."); Timer timer = new Timer(); long fileSize = 0, count = 0; // SimpleQuery query = new SimpleQuery(); // query.setMaxResults( 1000000 ); // for (IRecordState record : store.find( query )) { // fileSize += new CachedTile( record ).filesize.get(); // count ++; // } for (File f : dataDir.listFiles()) { fileSize += f.length(); count++; } dataDirSize = new AtomicLong(fileSize); log.info(" -> " + FileUtils.byteCountToDisplaySize(dataDirSize.get()) + " in " + count + " tiles" + " (" + timer.elapsedTime() + "ms)"); prefs.setDefault(PREF_TOTAL_STORE_SIZE, DEFAULT_MAX_STORE_SIZE); maxStoreSizeInByte = prefs.getInt(PREF_TOTAL_STORE_SIZE); } catch (Exception e) { log.error("Error starting Cache304.", e); } }
From source file:org.polymap.core.model2.test.SimpleModelTest.java
protected void logHeap() { System.gc();/* www. j a va 2 s.c o m*/ Runtime rt = Runtime.getRuntime(); log.info("HEAP: free/total: " + FileUtils.byteCountToDisplaySize(rt.freeMemory()) + " / " + FileUtils.byteCountToDisplaySize(rt.totalMemory())); }
From source file:org.polymap.p4.data.importer.download.DownloadImporter.java
@Override public void verify(IProgressMonitor monitor) { exception = null;//from w w w. j a v a 2 s . c om if (url != null) { monitor.beginTask("Downloading", IProgressMonitor.UNKNOWN); File tempDir = ImportTempDir.create(); downloaded = new File(tempDir, FilenameUtils.getName(url.getPath())); try (OutputStream out = new FileOutputStream(downloaded); InputStream in = url.openStream();) { Timer timer = new Timer(); byte[] buf = new byte[4096]; long count = 0; for (int c = in.read(buf); c > -1; c = in.read(buf)) { out.write(buf, 0, c); count += c; if (monitor.isCanceled()) { break; } else { monitor.subTask(FileUtils.byteCountToDisplaySize(count)); timer.start(); } } site.ok.set(true); } catch (Exception e) { site.ok.set(false); exception = e; return; } } else { site.ok.set(false); } }
From source file:org.polymap.p4.data.importer.download.DownloadImporter.java
@Override public void createResultViewer(Composite parent, IPanelToolkit tk) { if (downloaded != null) { tk.createFlowText(parent, "Download complete.\n\n" + "> " + downloaded.getName() + "\n\n" + "> " + FileUtils.byteCountToDisplaySize(downloaded.length())); } else {//from ww w.j a v a2 s. co m tk.createFlowText(parent, "Unable to download file."); if (exception != null) { tk.createFlowText(parent, "Reason: " + exception.getMessage()); } } }