Java Code Examples for org.apache.commons.io.FilenameUtils#removeExtension()
The following examples show how to use
org.apache.commons.io.FilenameUtils#removeExtension() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NativeCompiler.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public WorkResult execute(T spec) { boolean didWork = false; boolean windowsPathLimitation = OperatingSystem.current().isWindows(); String objectFileExtension = OperatingSystem.current().isWindows() ? ".obj" : ".o"; for (File sourceFile : spec.getSourceFiles()) { String objectFileName = FilenameUtils.removeExtension(sourceFile.getName()) + objectFileExtension; WorkResult result = commandLineTool.inWorkDirectory(spec.getObjectFileDir()) .withArguments(new SingleSourceCompileArgTransformer<T>(sourceFile, objectFileName, new ShortCircuitArgsTransformer(argsTransfomer), windowsPathLimitation, false)) .execute(spec); didWork = didWork || result.getDidWork(); } return new SimpleWorkResult(didWork); }
Example 2
Source File: DOTRendering.java From textuml with Eclipse Public License 1.0 | 6 votes |
public static byte[] generateDOTFromModel(URI modelURI, Collection<EObject> modelContents, IRendererSelector<? extends EObject> selector, IRenderingSettings settings, Map<String, Map<String, Object>> defaultDotSettings) throws CoreException { StringWriter sw = new StringWriter(); IndentedPrintWriter out = new IndentedPrintWriter(sw); IRenderingSession session = new RenderingSession(selector, settings, out); String modelName = FilenameUtils.removeExtension(FilenameUtils.getName(modelURI.getPath())); printPrologue(modelName, defaultDotSettings, out); boolean anyRendered = RenderingUtils.renderAll(session, modelContents); if (!anyRendered) { out.println("NIL [ label=\"No objects selected for rendering\"]"); } printEpilogue(out); out.close(); byte[] dotContents = sw.getBuffer().toString().getBytes(); if (Boolean.getBoolean(ID + ".showDOT")) { LogUtils.log(IStatus.INFO, ID, "DOT output for " + modelURI, null); LogUtils.log(IStatus.INFO, ID, sw.getBuffer().toString(), null); } if (Boolean.getBoolean(ID + ".showMemory")) System.out.println("*** free: " + toMB(Runtime.getRuntime().freeMemory()) + " / total: " + toMB(Runtime.getRuntime().totalMemory()) + " / max: " + toMB(Runtime.getRuntime().maxMemory())); return dotContents; }
Example 3
Source File: IOUtils.java From poor-man-transcoder with GNU General Public License v2.0 | 6 votes |
public static ITranscoderResource createOutputFromInput(ITranscoderResource in, ITranscoderResource temp, TokenReplacer tokenReplacer) throws URISyntaxException, InvalidTranscoderResourceException{ IMedia finalOutput = null; IContainer container = null; String insource = in.getSourcePath(); String outsource = temp.getSourcePath(); String streamname = FilenameUtils.removeExtension(in.getMediaName()); tokenReplacer.setTokenValue(TokenReplacer.TOKEN.SOURCE_STREAM_TOKEN, streamname); tokenReplacer.setTokenValue(TokenReplacer.TOKEN.SOURCE_STREAM_TOKEN_2, streamname); String inapp = insource.substring(0, insource.indexOf(streamname)-1); tokenReplacer.setTokenValue(TokenReplacer.TOKEN.SOURCE_APP_TOKEN, inapp); tokenReplacer.setTokenValue(TokenReplacer.TOKEN.SOURCE_APP_TOKEN_2, inapp); outsource = tokenReplacer.processReplacement(outsource); container = (temp.getContainer() == null)?new Container(guessContainer(outsource)):temp.getContainer(); finalOutput = (temp.isStreamingMedia())?new StreamMedia(outsource, container):new FileMedia(outsource, container); finalOutput.setContainer(container); return new SimpleTranscoderResource(finalOutput); }
Example 4
Source File: CrushedPNGFileSystem.java From ghidra with Apache License 2.0 | 6 votes |
@Override public void open(TaskMonitor monitor) throws IOException, CryptoException, CancelledException { BinaryReader reader = new BinaryReader(provider, false); monitor.setMessage("Opening iOS Crushed PNG..."); this.png = new ProcessedPNG(reader, monitor); String uncrushedPngFilename = getName(); //Remove the .png extension and then replace with .uncrushed.png extension if ("png".equalsIgnoreCase(FilenameUtils.getExtension(uncrushedPngFilename))) { uncrushedPngFilename = FilenameUtils.removeExtension(uncrushedPngFilename) + ".uncrushed.png"; } pngGFile = GFileImpl.fromFilename(this, root, uncrushedPngFilename, false, 1, null); }
Example 5
Source File: DexToJarFileSystem.java From ghidra with Apache License 2.0 | 5 votes |
@Override public void open(TaskMonitor monitor) throws CancelledException, IOException { FileCacheEntry jarFileInfo = getJarFile(monitor); FSRLRoot targetFSRL = getFSRL(); FSRL containerFSRL = targetFSRL.getContainer(); String baseName = FilenameUtils.removeExtension(containerFSRL.getName()); String jarName = baseName + ".jar"; FSRL jarFSRL = targetFSRL.withPathMD5(jarName, jarFileInfo.md5); this.jarFile = GFileImpl.fromFilename(this, root, baseName + ".jar", false, jarFileInfo.file.length(), jarFSRL); }
Example 6
Source File: DefinitionFileFinder.java From swaggerhub-maven-plugin with Apache License 2.0 | 5 votes |
/** * Given a directory and the optional regex pattern, find API definitions. * Definitions should be contained in a file with one of the following extensions: .json, .yml, .yaml. * @param directory * @param fileNameRegexPattern * @return * @throws IOException - Returned when the directory specified cannot be found */ public static List<File> findDefinitionFiles(String directory, Optional<String> fileNameRegexPattern) throws IOException { File directoryFile = new File(modifyPathForOperatingFileSystem(directory)); if(!directoryFile.exists()){ throw new IOException(String.format("The given directory [%s] cannot be found", directory)); } ArrayList<File> files = new ArrayList<>(); File[] childFiles = directoryFile.listFiles(); for (File childFile:childFiles){ String fileExtension = FilenameUtils.getExtension(childFile.getName()); String fileNameWithoutExtension = FilenameUtils.removeExtension(childFile.getName()); boolean fileExtensionTypeIsSupported = DefinitionFileFormat.getByFileExtensionType(fileExtension).isPresent(); if(!fileExtensionTypeIsSupported){ continue; } boolean addFile = fileNameRegexPattern .map(pattern -> fileNameWithoutExtension.matches(pattern)) .orElse(!fileNameRegexPattern.isPresent()); if(addFile){ files.add(childFile); } } return files; }
Example 7
Source File: PageRenderController.java From engine with GNU General Public License v3.0 | 5 votes |
protected String getScriptUrl(SiteContext siteContext, ScriptFactory scriptFactory, HttpServletRequest request, String pageUrl) { String method = request.getMethod().toLowerCase(); String pageUrlNoExt = FilenameUtils.removeExtension(pageUrl); String controllerScriptsPath = siteContext.getControllerScriptsPath(); String baseUrl = UrlUtils.concat(controllerScriptsPath, pageUrlNoExt); return String.format(SCRIPT_URL_FORMAT, baseUrl, method, scriptFactory.getScriptFileExtension()); }
Example 8
Source File: DefaultTestScriptStorage.java From sailfish-core with Apache License 2.0 | 5 votes |
private TestScriptDescription getReport(File reportFile, Path relativeReportPath) { String reportRootPath = reportFile.toString(); try { if (FilenameUtils.isExtension(reportRootPath, ZipReport.ZIP_EXTENSION)) { try (ZipFile zipFile = new ZipFile(reportFile)) { String entryToExtract = FilenameUtils.removeExtension(reportFile.getName()) + "/" + ROOT_JSON_REPORT_ZIP_ENTRY; logger.debug("Extract entry {}", entryToExtract); ZipEntry zipJson = zipFile.getEntry(entryToExtract); try (InputStream stream = zipFile.getInputStream(zipJson)) { return convertToTestScriptDescription(FilenameUtils.removeExtension(relativeReportPath.toString()), jsonObjectMapper.readValue(stream, ReportRoot.class)); } } } else if (FilenameUtils.isExtension(reportRootPath, JSON_EXTENSION)) { try (InputStream stream = new FileInputStream(reportFile)) { return convertToTestScriptDescription(relativeReportPath.getParent().getParent().toString(), jsonObjectMapper.readValue(stream, ReportRoot.class)); } } else { throw new IllegalArgumentException(String.format("Unknown file extension '%s'", FilenameUtils.getExtension(reportRootPath))); } } catch (Exception e) { logger.error(String.format("Unable to parse report '%s'", reportRootPath), e); return null; } }
Example 9
Source File: TiffAsJpegImporter.java From proarc with GNU General Public License v3.0 | 5 votes |
private FileEntry convertToTiff(FileEntry jp, Configuration processorConfig) throws IOException { if (processorConfig == null || processorConfig.isEmpty()) { throw new IllegalArgumentException("Convertor config must be set."); } File tiff = new File( jp.getFile().getParent(), FilenameUtils.removeExtension(jp.getFile().getName()) + ".tiff"); //conversion was done before if (tiff.exists()) { return null; } String processorType = processorConfig.getString("type"); ExternalProcess process; if (GhostConvert.ID.equals(processorType)) { process = new GhostConvert(processorConfig, jp.getFile(), tiff); } else if (VIPSConvert.ID.equals(processorType)) { process = new VIPSConvert(processorConfig, jp.getFile(), tiff); } else { throw new IllegalArgumentException("No suitable convertor found."); } process.run(); if (!process.isOk()) { throw new IOException(tiff.toString() + "\n" + process.getFullOutput()); } return new FileEntry(tiff); }
Example 10
Source File: FileNameObjectIdGenerator.java From cineast with MIT License | 5 votes |
@Override public String next(Path path, MediaType type) { if (path == null) { return "null"; } String filename = FilenameUtils.removeExtension(path.toFile().getName()); return MediaType.generateId(type, filename); }
Example 11
Source File: ProtoContext.java From protostuff-compiler with Apache License 2.0 | 4 votes |
private String getFilenameWithoutExtension(String filename) { String shortFilename = FilenameUtils.getName(filename); return FilenameUtils.removeExtension(shortFilename); }
Example 12
Source File: CppGradingLanguage.java From judgels with GNU General Public License v2.0 | 4 votes |
@Override public String getExecutableFilename(String sourceFilename) { return FilenameUtils.removeExtension(sourceFilename); }
Example 13
Source File: ThemeMojo.java From opoopress with Apache License 2.0 | 4 votes |
private void processParameters() throws MojoFailureException { if (name != null) { if (name.startsWith(OP_THEME_ARTIFACT_PREFIX)) { if (artifactId == null) { artifactId = name; } name = name.substring(OP_THEME_ARTIFACT_PREFIX_LENGTH); } else { if (artifactId == null) { artifactId = OP_THEME_ARTIFACT_PREFIX + name; } } } // URL url = null; if (theme != null) { String str = theme.toLowerCase(); //url if (str.startsWith("http://") || str.startsWith("https://")) { try { url = new URL(theme); } catch (MalformedURLException e) { throw new MojoFailureException("Not a valid url: " + theme, e); } if (name == null) { String filename = URIUtil.getName(theme); name = FilenameUtils.removeExtension(filename); } } else { //groupId:artifactId:version[:packaging][:classifier] String[] tokens = StringUtils.split(theme, ":"); if (tokens.length < 3 || tokens.length > 5) { throw new MojoFailureException( "Invalid theme artifact, you must specify groupId:artifactId:version[:packaging][:classifier] " + theme); } groupId = tokens[0]; artifactId = tokens[1]; version = tokens[2]; if (tokens.length >= 4) { type = tokens[3]; } if (tokens.length == 5) { classifier = tokens[4]; } else { classifier = null; } if (name == null) { if (artifactId.startsWith(OP_THEME_ARTIFACT_PREFIX)) { name = artifactId.substring(OP_THEME_ARTIFACT_PREFIX_LENGTH); } else { name = artifactId; } } } } }
Example 14
Source File: FuncotatorIntegrationTest.java From gatk with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Test(dataProvider = "provideForNonTrivialLargeDataValidationTest") public void nonTrivialLargeDataValidationTest(final String inputVcfName, final String referencePath, final String referenceVersion, final String dataSourcesPath, final String expectedOutputPath ) { for ( final FuncotatorArgumentDefinitions.OutputFormatType outputFormatType : FuncotatorArgumentDefinitions.OutputFormatType.values()) { // The CLI for Funcotator does not support SEG output. Must use FuncotateSegments for that. if (outputFormatType.equals(FuncotatorArgumentDefinitions.OutputFormatType.SEG)) { continue; } final String typeCorrectedExpectedOutPath = FilenameUtils.removeExtension(expectedOutputPath) + "." + outputFormatType.toString().toLowerCase(); final File outputFile = createTempFile(tmpOutDir + File.separator + inputVcfName + ".funcotator", "." + outputFormatType.toString().toLowerCase()); final ArgumentsBuilder arguments = createBaselineArgumentsForFuncotator( inputVcfName, outputFile, referencePath, dataSourcesPath, referenceVersion, outputFormatType, true); // Run the tool with our args: long startTime = 0, endTime = 0; startTime = System.nanoTime(); runCommandLine(arguments); endTime = System.nanoTime(); logger.warn(" " + outputFormatType.toString() + " Elapsed Time: " + (endTime - startTime) / 1e9 + "s"); // ======================================================== // Validate our output: if ( outputFormatType == FuncotatorArgumentDefinitions.OutputFormatType.VCF ) { // Get the actual data: assertEqualVariantFiles(outputFile, typeCorrectedExpectedOutPath); } else { try { IntegrationTestSpec.assertEqualTextFiles(outputFile, new File(typeCorrectedExpectedOutPath), "#"); } catch ( final IOException ex ) { throw new GATKException("Error opening expected file: " + expectedOutputPath, ex); } } } }
Example 15
Source File: LaunchServicesApplicationFinder.java From cyberduck with GNU General Public License v3.0 | 4 votes |
/** * Determine the human readable application name for a given bundle identifier. * * @param search Bundle identifier * @return Application human readable name */ @Override public Application getDescription(final String search) { if(applicationNameCache.contains(search)) { return applicationNameCache.get(search); } if(log.isDebugEnabled()) { log.debug(String.format("Find application for %s", search)); } final String identifier; final String name; synchronized(NSWorkspace.class) { final NSWorkspace workspace = NSWorkspace.sharedWorkspace(); final String path; if(null != workspace.absolutePathForAppBundleWithIdentifier(search)) { path = workspace.absolutePathForAppBundleWithIdentifier(search); } else { log.warn(String.format("Cannot determine installation path for bundle identifier %s. Try with name.", search)); path = workspace.fullPathForApplication(search); } if(StringUtils.isNotBlank(path)) { final NSBundle app = NSBundle.bundleWithPath(path); if(null == app) { log.error(String.format("Loading bundle %s failed", path)); identifier = search; name = FilenameUtils.removeExtension(new FinderLocal(path).getDisplayName()); } else { NSDictionary dict = app.infoDictionary(); if(null == dict) { log.error(String.format("Loading application dictionary for bundle %s failed", path)); applicationNameCache.put(search, Application.notfound); return null; } else { final NSObject bundlename = dict.objectForKey("CFBundleName"); if(null == bundlename) { log.warn(String.format("No CFBundleName in bundle %s", path)); name = FilenameUtils.removeExtension(new FinderLocal(path).getDisplayName()); } else { name = bundlename.toString(); } final NSObject bundleIdentifier = dict.objectForKey("CFBundleIdentifier"); if(null == bundleIdentifier) { log.warn(String.format("No CFBundleName in bundle %s", path)); identifier = search; } else { identifier = bundleIdentifier.toString(); } } } } else { log.warn(String.format("Cannot determine installation path for %s", search)); applicationNameCache.put(search, Application.notfound); return Application.notfound; } } final Application application = new Application(identifier, name); applicationNameCache.put(search, application); return application; }
Example 16
Source File: CGradingLanguage.java From judgels with GNU General Public License v2.0 | 4 votes |
@Override public String getExecutableFilename(String sourceFilename) { return FilenameUtils.removeExtension(sourceFilename); }
Example 17
Source File: RunShaderFamily.java From graphicsfuzz with Apache License 2.0 | 4 votes |
public static int runShaderFamily( File shaderFamilyDir, File outputDir, IShaderDispatcher imageGenerator, ShaderJobFileOperations fileOps) throws ShaderDispatchException, InterruptedException, IOException { int numShadersRun = 0; File referenceResult = new File(outputDir, "reference.info.json"); File referenceJob = new File(shaderFamilyDir, "reference.json"); if (!fileOps.doesShaderJobResultFileExist(referenceResult)) { runShader( referenceResult, referenceJob, imageGenerator, Optional.empty(), fileOps); ++numShadersRun; } if (!fileOps.isComputeShaderJob(referenceJob)) { if (!fileOps.doesShaderJobResultFileHaveImage(referenceResult)) { LOGGER.info("Reference failed to render, so skipping variants."); return numShadersRun; } } final File[] variants = fileOps.listShaderJobFiles(shaderFamilyDir, (dir, name) -> name.startsWith("variant")); for (File variant : variants) { final String variantName = FilenameUtils.removeExtension(variant.getName()); final File resultFile = new File(outputDir, variantName + ".info.json"); if (fileOps.doesShaderJobResultFileExist(resultFile)) { LOGGER.info("Skipping {} because we already have a result.", variant); } else { try { runShader( resultFile, variant, imageGenerator, Optional.of(referenceResult), fileOps); } catch (Exception err) { LOGGER.error("runShader() raise exception on {}", variant); err.printStackTrace(); } ++numShadersRun; } } return numShadersRun; }
Example 18
Source File: TLApiDumpTest.java From kotlogram with MIT License | 4 votes |
@Override public String getTestName() { return FilenameUtils.removeExtension(file.getName()); }
Example 19
Source File: Assembler.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public AssembleSpecToArgsList(File inputFile, File objectFileRootDir, String outputFileSuffix) { this.inputFile = inputFile; String outputFileName = FilenameUtils.removeExtension(inputFile.getName())+ outputFileSuffix; File currentObjectOutputDir = new File(objectFileRootDir, HashUtil.createCompactMD5(inputFile.getAbsolutePath())); this.outputFile = new File(currentObjectOutputDir, outputFileName); }
Example 20
Source File: FileAndPathUtil.java From mzmine3 with GNU General Public License v2.0 | 2 votes |
/** * Returns the real file name as filename.fileformat * * @param name * @param format a format starting with a dot for example .pdf * @return */ public static String getRealFileName(String name, String format) { String result = FilenameUtils.removeExtension(name); result = addFormat(result, format); return result; }