List of usage examples for org.apache.commons.io FilenameUtils getBaseName
public static String getBaseName(String filename)
From source file:ffx.ui.FFXSystem.java
/** * Constructor./*from ww w.ja va2 s .co m*/ * * @param file Coordinate file. * @param description Short description of the command that created this * system. * @param properties Properties controlling operations on this system. */ public FFXSystem(File file, String description, CompositeConfiguration properties) { super(FilenameUtils.getBaseName(file.getName())); setFile(file); commandDescription = description; this.properties = properties; }
From source file:de.tudarmstadt.ukp.dkpro.keyphrases.bookindexing.evaluation.phrasematch.LineReader.java
/** * @param jcas/*from w ww . j ava 2 s . com*/ * @return the document basename from the parsed document-URI-path. * @throws AnalysisEngineProcessException */ private String getDocumentBaseName(JCas jcas) throws AnalysisEngineProcessException { try { URI uri = new URI(DocumentMetaData.get(jcas).getDocumentUri()); return FilenameUtils.getBaseName(uri.getPath()); } catch (URISyntaxException e) { throw new AnalysisEngineProcessException(e); } }
From source file:au.org.ala.delta.key.KeyContext.java
public KeyContext(File directivesFile, PrintStream out, PrintStream err) { super(out, err); if (!directivesFile.exists() || directivesFile.isDirectory()) { throw new IllegalArgumentException( String.format("****** File %s does not exist.", directivesFile.toString())); }// www. j av a 2 s . co m this._directivesFile = directivesFile; this._dataDirectory = directivesFile.getParentFile(); KeyOutputFileManager outputFileManager = (KeyOutputFileManager) _outputFileSelector; try { outputFileManager.setOutputDirectory(_dataDirectory.getAbsolutePath()); outputFileManager.setTypesettingFileOutputDirectory(_dataDirectory); } catch (Exception ex) { throw new RuntimeException("Error setting output directory"); } outputFileManager.setDefaultBaseFileName(FilenameUtils.getBaseName(directivesFile.getName())); _typesetFilesOutputDirectory = _dataDirectory; _aBase = 2; _rBase = 1.4; _reuse = 1.01; _varyWt = 0.8; _stopAfterColumnNumber = -1; _truncateTabularKeyAtColumnNumber = -1; _charactersFile = new File(_dataDirectory, "kchars"); _itemsFile = new File(_dataDirectory, "kitems"); _addCharacterNumbers = false; _displayBracketedKey = true; _displayTabularKey = true; _allowImproperSubgroups = false; _treatUnknownAsInapplicable = false; _presetCharacters = new LinkedHashMap<Pair<Integer, Integer>, Integer>(); _characterCosts = null; _calculatedItemAbundanceValues = null; _taxonVariableCharacters = new HashMap<Integer, Set<Integer>>(); }
From source file:de.mpg.imeji.presentation.servlet.DigilibServlet.java
@Override public void init(ServletConfig config) throws ServletException { PropertyBean propBean = new PropertyBean(); if (propBean.isDigilibEnabled()) { try {/* w w w .ja v a 2 s . co m*/ authorization = new Authorization(); navigation = new Navigation(); } catch (Exception e) { throw new RuntimeException(e); } storageController = new StorageController(); InternalStorageManager ism = new InternalStorageManager(); internalStorageBase = FilenameUtils .getBaseName(FilenameUtils.normalizeNoEndSeparator(ism.getStoragePath())); // Copy the digilib-config.xml before initialising the digilib servlet, which needs this file copyFile(getDigilibConfigPath(), config.getServletContext().getRealPath("/WEB-INF")); super.init(config); } else { logger.info("Digilib Viewer is disabled."); } }
From source file:de.uzk.hki.da.format.TiffConversionStrategy.java
@Override public List<Event> convertFile(ConversionInstruction ci) { List<Event> resultEvents = new ArrayList<Event>(); String input = ci.getSource_file().toRegularFile().getAbsolutePath(); if (getEncoding(input).equals("None")) return resultEvents; // create subfolder if necessary Path.make(object.getPath("newest"), ci.getTarget_folder()).toFile().mkdirs(); String[] commandAsArray = new String[] { "convert", "+compress", input, generateTargetFilePath(ci) }; logger.info("Executing conversion command: {}", commandAsArray); ProcessInformation pi = CommandLineConnector.runCmdSynchronously(commandAsArray); if (pi.getExitValue() != 0) { logger.error(/*from w w w.ja v a2s . co m*/ this.getClass() + ": Recieved return code from terminal based command: " + pi.getExitValue()); throw new RuntimeException("cli conversion failed!\n\nstdOut: ------ \n\n\n" + pi.getStdOut() + "\n\n ----- end of stdOut\n\nstdErr: ------ \n\n\n" + pi.getStdErr() + "\n\n ----- end of stdErr"); } File result = new File(generateTargetFilePath(ci)); String baseName = FilenameUtils.getBaseName(result.getAbsolutePath()); String extension = FilenameUtils.getExtension(result.getAbsolutePath()); logger.info("Finding files matching wildcard expression \"" + baseName + "*." + extension + "\" in order to check them and test if conversion was successful"); List<File> results = findFilesWithWildcard(new File(FilenameUtils.getFullPath(result.getAbsolutePath())), baseName + "*." + extension); for (File f : results) { DAFile daf = new DAFile(pkg, object.getPath("newest").getLastElement(), Utilities.slashize(ci.getTarget_folder()) + f.getName()); logger.debug("new dafile:" + daf); Event e = new Event(); e.setType("CONVERT"); e.setDetail(Utilities.createString(commandAsArray)); e.setSource_file(ci.getSource_file()); e.setTarget_file(daf); e.setDate(new Date()); resultEvents.add(e); } return resultEvents; }
From source file:com.bt.download.android.gui.transfers.YouTubeDownload.java
YouTubeDownload(TransferManager manager, YouTubeCrawledSearchResult sr) { this.manager = manager; this.sr = sr; this.downloadType = buildDownloadType(sr); this.size = sr.getSize(); String filename = sr.getFilename(); File savePath = SystemPaths.getTorrentData(); completeFile = buildFile(savePath, filename); tempVideo = buildTempFile(FilenameUtils.getBaseName(filename), "video"); tempAudio = buildTempFile(FilenameUtils.getBaseName(filename), "audio"); bytesReceived = 0;/* w w w . jav a2 s.c o m*/ dateCreated = new Date(); httpClientListener = new HttpDownloadListenerImpl(); httpClient = HttpClientFactory.newInstance(); httpClient.setListener(httpClientListener); if (savePath == null) { this.status = STATUS_SAVE_DIR_ERROR; } if (!savePath.isDirectory() && !savePath.mkdirs()) { this.status = STATUS_SAVE_DIR_ERROR; } }
From source file:com.github.cbismuth.fdupes.io.PathOrganizer.java
private void onNoTimestampPath(final Path destination, final PathElement pathElement, final AtomicInteger counter) { final Path path = pathElement.getPath(); final String baseName = FilenameUtils.getBaseName(path.toString()); final int count = counter.getAndIncrement(); final String extension = FilenameUtils.getExtension(path.toString()); final String newName = String.format("%s-%d.%s", baseName, count, extension); final Path sibling = path.resolveSibling(newName); try {//from w w w. j av a 2s .c om FileUtils.moveFile(path.toFile(), sibling.toFile()); FileUtils.moveFileToDirectory(sibling.toFile(), Paths.get(destination.toString(), "misc").toFile(), true); } catch (final IOException e) { LOGGER.error(e.getMessage()); } }
From source file:com.uas.Files.FilesDAO.java
@Override public File getUniqueFilename(File file) { String baseName = FilenameUtils.getBaseName(file.getName()); String extension = FilenameUtils.getExtension(file.getName()); int counter = 1; while (file.exists()) { file = new File(file.getParent(), baseName + "-" + (counter++) + "." + extension); }//from w w w . ja va2 s . c om return file; }
From source file:com.splunk.shuttl.archiver.filesystem.PathResolver.java
/** * Resolves index from a Path to a bucket.<br/> * <br/>// w w w . j a v a 2 s .c o m * * @param bucketPath * , Path needs to have the index in a structure decided by a * {@link PathResolver}. */ public String resolveIndexFromPathToBucket(String bucketPath) { String parentWhichIsIndex = getParent(UtilsURI.getPathByTrimmingEndingFileSeparator(bucketPath)); return FilenameUtils.getBaseName(parentWhichIsIndex); }
From source file:codes.thischwa.c5c.requestcycle.impl.FilemanagerIconResolver.java
protected void collectIcons(String iconPath, java.nio.file.Path iconFolder, PathBuilder urlPath) { Map<String, String> iconsPerType = new HashMap<>(); try {/*from www . j a v a 2 s .c om*/ for (java.nio.file.Path icon : Files.newDirectoryStream(iconFolder, new DirectoryStream.Filter<java.nio.file.Path>() { @Override public boolean accept(java.nio.file.Path entry) throws IOException { if (Files.isDirectory(entry)) return false; String name = entry.getFileName().toString(); return !name.contains("_") && name.endsWith("png"); } })) { String name = icon.getFileName().toString(); String knownExtension = FilenameUtils.getBaseName(name); iconsPerType.put(knownExtension, urlPath.addFile(name)); } } catch (IOException e) { throw new RuntimeException("Couldn't read the icon files!", e); } iconsPerType.put(IconResolver.key_directory, urlPath.addFile(directoryIcon)); iconsPerType.put(IconResolver.key_default, urlPath.addFile(defaultIcon)); iconsPerType.put(IconResolver.key_directory_lock, urlPath.addFile("locked_" + directoryIcon)); iconsPerType.put(IconResolver.key_default_lock, urlPath.addFile("locked_" + defaultIcon)); iconCache.put(iconPath, new IconRequestResolver(iconsPerType)); }