List of usage examples for org.apache.commons.io FilenameUtils getBaseName
public static String getBaseName(String filename)
From source file:com.hortonworks.streamline.streams.cluster.register.impl.AbstractServiceRegistrar.java
private String getConfType(String fileName) { // treat confType as the file name without extension return FilenameUtils.getBaseName(fileName); }
From source file:eu.openanalytics.rsb.DirectoryDepositITCase.java
protected File ponderUntilJobError(final String jobFileName) throws InterruptedException { final File expectedAcceptedFile = new File(resultsDirectory, "result-" + FilenameUtils.getBaseName(jobFileName) + ".txt"); ponderForFile(expectedAcceptedFile); return expectedAcceptedFile; }
From source file:fr.ippon.wip.config.dao.XMLConfigurationDAO.java
@Override public List<String> getConfigurationsNames() { List<String> configurationNames = new ArrayList<String>(); for (String filename : new File(pathConfigFiles).list()) if (filename.endsWith(".xml")) configurationNames.add(FilenameUtils.getBaseName(filename)); Collections.sort(configurationNames); return configurationNames; }
From source file:edu.si.services.camel.extractor.ExtractorComponentTest.java
public void testExtractor(String archive, boolean delete) throws Exception { File file = new File(this.getClass().getResource("/" + archive).toURI()); boolean isNoFileExtTest = file.getName().contains(".") ? false : true; LOG.debug("Testing For File Ext: {}", isNoFileExtTest); MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMinimumMessageCount(msgCount + 1); File body = null;/* w ww.j a v a2 s .com*/ try { template.sendBody("direct:start", file); Message msg = mock.getExchanges().get(msgCount++).getIn(); body = msg.getBody(File.class); int numFiles = countFilesInArchive(file); assertNotNull("Results should not be null", body); assertTrue("Results should be a directory", body.isDirectory()); assertTrue("Directory name should match archive name", FilenameUtils.getBaseName(archive).equals(msg.getHeader("CamelFileNameOnly"))); assertEquals("Parent directory should be 'TestCameraTrapData'", "TestCameraTrapData", body.getParentFile().getName()); assertEquals("Directory should contain " + numFiles + " elements", numFiles, body.list().length); LOG.debug("Result body is not null: {}", (body != null)); LOG.debug("Result body should be a directory: {}", body.isDirectory()); LOG.debug("Result body parent File is: {}", body.getParentFile().getName()); LOG.debug("Num of files in archive: {}, Num of files in result body: {}", numFiles, body.list().length); } catch (CamelExecutionException e) { assertTrue("Exception should be ExtractorException", e.getExchange().getException() instanceof ExtractorException); expectedExceptionMsg = new StringBuilder(); if (isNoFileExtTest) { expectedExceptionMsg .append("Improperly formatted file. No, file extension found for " + file.getName()); } else { expectedExceptionMsg.append("Extracting archive '" + file.getName() + "' failed! "); expectedExceptionMsg.append("Directory '" + getDirName(file) + "' found in archive!"); } assertEquals("Exception messages are equal", expectedExceptionMsg.toString(), e.getExchange().getException().getMessage()); mock.setMinimumExpectedMessageCount(msgCount); LOG.debug("Testing Exchange Failed! Exception thrown was: '{}'", e.getExchange().getException().toString()); } catch (Exception ex) { delete = true; throw ex; } finally { if (delete && body != null && body.isDirectory()) { FileUtils.deleteDirectory(body); } } assertMockEndpointsSatisfied(); }
From source file:com.googlecode.l10nmavenplugin.model.BundlePropertiesFamily.java
/** * Get the base name of bundle, based on default {@link java.util.ResourceBundle} convention * baseName[_language[_country[_variant]]].properties * //w ww .ja v a2s .c om * @param propertiesName * file name of 1 properties of the bundle * @return baseName of the bundle */ protected String getBundleBaseName(String propertiesName) { int index = propertiesName.indexOf(SEPARATOR); if (index != -1) { return propertiesName.substring(0, index); } else { return FilenameUtils.getBaseName(propertiesName); } }
From source file:com.frostwire.android.gui.Librarian.java
public String renameFile(final Context context, FileDescriptor fd, String newFileName) { try {/*from www . j ava 2s. c o m*/ String filePath = fd.filePath; File oldFile = new File(filePath); String ext = FilenameUtils.getExtension(filePath); File newFile = new File(oldFile.getParentFile(), newFileName + '.' + ext); ContentResolver cr = context.getContentResolver(); ContentValues values = new ContentValues(); values.put(MediaColumns.DATA, newFile.getAbsolutePath()); values.put(MediaColumns.DISPLAY_NAME, FilenameUtils.getBaseName(newFileName)); values.put(MediaColumns.TITLE, FilenameUtils.getBaseName(newFileName)); TableFetcher fetcher = TableFetchers.getFetcher(fd.fileType); cr.update(fetcher.getContentUri(), values, BaseColumns._ID + "=?", new String[] { String.valueOf(fd.id) }); oldFile.renameTo(newFile); return newFile.getAbsolutePath(); } catch (Throwable e) { Log.e(TAG, "Failed to rename file: " + fd, e); } return null; }
From source file:net.sourceforge.atunes.kernel.modules.repository.AudioFile.java
/** * Gets the name without extension./* w w w . j a va 2 s . co m*/ * * @return the name without extension */ @Override public String getNameWithoutExtension() { return FilenameUtils.getBaseName(this.filePath); }
From source file:com.teradata.tempto.internal.convention.sql.SqlQueryConventionBasedTest.java
@Override public String testName() { String testName = FilenameUtils.getBaseName(queryFile.getParent().toString()); if (!isAlphabetic(testName.charAt(0))) { return "Test" + testName; }// w w w . j av a2s . c om return testName; }
From source file:com.scooter1556.sms.server.io.AdaptiveStreamingProcess.java
public void initialise() { // Stop transcode process if one is already running if (process != null) { process.destroy();/*from ww w. ja v a 2 s . co m*/ } // Determine stream directory streamDirectory = new File(SettingsService.getInstance().getCacheDirectory().getPath() + "/streams/" + id); try { if (streamDirectory.exists()) { // Wait for process to finish if (process != null) { process.waitFor(); } FileUtils.cleanDirectory(streamDirectory); } else { boolean success = streamDirectory.mkdirs(); if (!success) { LogService.getInstance().addLogEntry(Level.ERROR, CLASS_NAME, "Unable to create directory " + streamDirectory.getPath(), null); return; } } // Reset flags ended = false; // Setup post-processing of audio segments if required if (postProcessEnabled && audioTranscodes != null && mediaElement != null && transcoder != null) { // Setup thread pool for post-processing segments postProcessExecutor = Executors.newCachedThreadPool(); // Setup directory watcher watcher = new DirectoryWatcher.Builder().addDirectories(streamDirectory.getPath()) .setPreExistingAsCreated(true).build(new DirectoryWatcher.Listener() { @Override public void onEvent(DirectoryWatcher.Event event, final Path path) { switch (event) { case ENTRY_CREATE: // Check if we are interested in this file if (!FilenameUtils.getExtension(path.toString()).isEmpty() || !path.getFileName().toString().contains("audio")) { break; } // Get the information we require String[] segmentData = FilenameUtils.getBaseName(path.getFileName().toString()) .split("-"); if (segmentData.length < 3) { break; } // Variables final int transcode = Integer.parseInt(segmentData[2]); // Retrive transcode format if (audioTranscodes.length < transcode || mediaElement == null) { break; } // Determine codec AudioTranscode aTranscode = audioTranscodes[transcode]; String codec = aTranscode.getCodec(); if (codec.equals("copy")) { codec = MediaUtils.getAudioStreamById(mediaElement.getAudioStreams(), aTranscode.getId()).getCodec(); } final String format = TranscodeUtils.getFormatForAudioCodec(codec); // Transcode postProcessExecutor.submit(new Runnable() { @Override public void run() { postProcess(path.toString(), format); } }); break; case ENTRY_MODIFY: break; case ENTRY_DELETE: break; } } }); // Start directory watcher watcher.start(); } // Start transcoding start(); } catch (Exception ex) { if (process != null) { process.destroy(); } if (watcher != null) { watcher.stop(); } if (postProcessExecutor != null && !postProcessExecutor.isTerminated()) { postProcessExecutor.shutdownNow(); } ended = true; LogService.getInstance().addLogEntry(Level.ERROR, CLASS_NAME, "Error starting adaptive streaming process.", ex); } }
From source file:com.piketec.jenkins.plugins.tpt.Utils.java
/** * Creates a String with a path to create for the report dir. This will be relative to the build * workspace//from w ww . j a v a2 s. co m * * @param ec * through the jenkins configuration we get the name and the configuration of the file. * Used to create an unique path. * @return a String with the folders for the report dir. */ public static String getGeneratedReportDir(JenkinsConfiguration ec) { if (ec.getReportDir() == null || ec.getReportDir().trim().isEmpty()) { return "Piketec" + File.separator + FilenameUtils.getBaseName(ec.getTptFile()) + File.separator + ec.getConfiguration() + File.separator + "report"; } else { return ec.getReportDir(); } }