List of usage examples for org.apache.commons.io FilenameUtils getBaseName
public static String getBaseName(String filename)
From source file:ijfx.core.image.sampler.DatasetSamplerService.java
/** * Isolate a point of a dimension of a dataset. It means for instance that * if you have a dataset with CHANNEL and Z, you can isolate a the Z stack * corresponding to a single channel just by doing : * sampleService.isolateDimension(myDataset,Axes.CHANNEL,2) * * @param dataset the input dataset//from w w w .j a va2 s . c o m * @param axes the axe type to isolate * @param position the position in the dimension * @return */ public Dataset isolateDimension(Dataset dataset, AxisType axes, long position) { SamplingDefinition def = new SamplingDefinition(dataset); AxisSubrange subrange = new AxisSubrange(position); def.constrain(axes, subrange); Dataset output = createOutputImage(dataset, def); copyData(def, dataset, output); String name = output.getName(); name = FilenameUtils.getBaseName(name); String extension = FilenameUtils.getExtension(output.getName()); output.setName(String.format("%s - %s %d.%s", name, axes.getLabel(), position, extension)); return output; }
From source file:net.pms.dlna.RarredEntry.java
@Override public String getSystemName() { return FilenameUtils.getBaseName(file.getAbsolutePath()) + "." + FilenameUtils.getExtension(name); }
From source file:ch.cyberduck.core.transfer.normalizer.DownloadRootPathsNormalizer.java
@Override public List<TransferItem> normalize(final List<TransferItem> roots) { final List<TransferItem> normalized = new ArrayList<TransferItem>(); for (final TransferItem download : roots) { boolean duplicate = false; for (Iterator<TransferItem> iter = normalized.iterator(); iter.hasNext();) { TransferItem n = iter.next(); if (download.remote.isChild(n.remote)) { // The selected file is a child of a directory already included duplicate = true;/*from w ww . j a v a 2 s . c om*/ break; } if (n.remote.isChild(download.remote)) { iter.remove(); } if (download.local.equals(n.local)) { // The selected file has the same name; if downloaded as a root element // it would overwrite the earlier final String parent = download.local.getParent().getAbsolute(); final String filename = download.remote.getName(); String proposal; int no = 0; Local local; do { proposal = String.format("%s-%d", FilenameUtils.getBaseName(filename), ++no); if (StringUtils.isNotBlank(FilenameUtils.getExtension(filename))) { proposal += String.format(".%s", FilenameUtils.getExtension(filename)); } local = LocalFactory.get(parent, proposal); } while (local.exists()); if (log.isInfoEnabled()) { log.info(String.format("Changed local name from %s to %s", filename, local.getName())); } download.local = local; } } // Prunes the list of selected files. Files which are a child of an already included directory // are removed from the returned list. if (!duplicate) { normalized.add(new TransferItem(download.remote, download.local)); } } return normalized; }
From source file:com.yattatech.domain.Seminary.java
public String getPdfReportFilename() { return FilenameUtils.getBaseName(filePath) + ".pdf"; }
From source file:ch.cyberduck.ui.cocoa.controller.DuplicateFileController.java
@Override public NSView getAccessoryView(final NSAlert alert) { final NSView view = super.getAccessoryView(alert); String proposal = MessageFormat.format(PreferencesFactory.get().getProperty("browser.duplicate.format"), FilenameUtils.getBaseName(selected.getName()), UserDateFormatterFactory.get().getShortFormat(System.currentTimeMillis(), false) .replace(Path.DELIMITER, ':'), StringUtils.isNotBlank(selected.getExtension()) ? String.format(".%s", selected.getExtension()) : StringUtils.EMPTY); this.updateField(inputField, proposal); return view;/*from w ww . j a va2 s. co m*/ }
From source file:ch.cyberduck.ui.cocoa.FileController.java
protected void focus(final NSTextField control) { // Focus accessory view. control.selectText(null);//from www. jav a 2s. c o m window.makeFirstResponder(control); control.currentEditor().setSelectedRange(NSRange.NSMakeRange(new NSUInteger(0), new NSUInteger(FilenameUtils.getBaseName(control.stringValue()).length()))); }
From source file:com.siberhus.tdfl.DefaultResourceCreator.java
@Override public Resource create(Resource example) throws IOException { String parent = example.getFile().getParent(); String targetDirPath = parent + File.separator + subdirectory; File targetDir = new File(targetDirPath); if (!targetDir.exists()) { if (createDirectory) { targetDir.mkdir();/* w w w . j a v a 2s.c om*/ } } String filename = example.getFilename(); if (extension == null) extension = FilenameUtils.getExtension(filename); filename = FilenameUtils.getBaseName(filename); if (prefix != null) { filename = prefix + filename; } if (suffix != null) { filename = filename + suffix; } filename = filename + "." + extension; return new FileSystemResource(targetDirPath + File.separator + filename); }
From source file:de.xirp.profile.ProfileGenerator.java
/** * Generates a PRO file with the given path from the given * {@link de.xirp.profile.Profile profile} bean. * /*from w w w .j a v a2 s.com*/ * @param profile * The profile to generate the XML for. * @param proFile * The file to write the result to. Must be the full path. * * @throws JAXBException if the given profile was null, or something * went wrong generating the xml. * @throws FileNotFoundException if something went wrong generating the xml. * * @see de.xirp.profile.Profile */ public static void generatePRO(Profile profile, File proFile) throws JAXBException, FileNotFoundException { if (profile == null) { throw new JAXBException(I18n.getString("ProfileGenerator.exception.profileNull")); //$NON-NLS-1$ } String fileName = FilenameUtils.getBaseName(proFile.getName()); JAXBContext jc = JAXBContext.newInstance(Profile.class); Marshaller m = jc.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); m.marshal(profile, new FileOutputStream( Constants.CONF_PROFILES_DIR + File.separator + fileName + Constants.PROFILE_POSTFIX)); }
From source file:MSUmpire.SeqUtility.FastaParser.java
public static FastaParser FasterSerialzationRead(String Filename) throws FileNotFoundException { if (!new File(FilenameUtils.getFullPath(Filename) + FilenameUtils.getBaseName(Filename) + ".FastaSer") .exists()) {/*w ww . j a v a 2 s . c om*/ return null; } FastaParser fastareader = null; try { org.apache.log4j.Logger.getRootLogger().info("Loading fasta serialization to file:" + FilenameUtils.getFullPath(Filename) + FilenameUtils.getBaseName(Filename) + ".FastaSer.."); FileInputStream fileIn = new FileInputStream( FilenameUtils.getFullPath(Filename) + FilenameUtils.getBaseName(Filename) + ".FastaSer"); FSTObjectInput in = new FSTObjectInput(fileIn); fastareader = (FastaParser) in.readObject(); in.close(); fileIn.close(); } catch (Exception ex) { org.apache.log4j.Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex)); return null; } return fastareader; }
From source file:com.frostwire.search.monova.MonovaSearchResult.java
public MonovaSearchResult(String detailsUrl, SearchMatcher matcher) { /*/* w w w .ja v a 2 s . c o m*/ * Matcher groups cheatsheet * 1 -> .torrent URL * 2 -> infoHash * 3 -> seeds * 4 -> SIZE (B|KiB|MiBGiB) */ this.detailsUrl = detailsUrl; this.filename = parseFileName(FilenameUtils.getName(matcher.group(1))); this.displayName = parseDisplayName( HtmlManipulator.replaceHtmlEntities(FilenameUtils.getBaseName(filename))); this.infoHash = matcher.group(5); this.creationTime = parseCreationTime(matcher.group(2)); this.size = parseSize(matcher.group(4)); this.seeds = parseSeeds(matcher.group(3)); // Monova can't handle direct download of torrents without some sort of cookie //the torcache url wont resolve into direct .torrent this.torrentUrl = "magnet:?xt=urn:btih:" + infoHash; }