List of usage examples for org.apache.commons.io FilenameUtils removeExtension
public static String removeExtension(String filename)
From source file:org.astrojournal.generator.absgen.LatexExporter.java
@Override public void postProcessing() throws IOException { // The pdflatex command must be called two times in order to // generate the list of contents correctly. String commandOutput;// w w w . ja va 2 s . c o m RunExternalCommand extCommand = new RunExternalCommand(filesLocation, resourceBundle); commandOutput = extCommand.runCommand(command + " " + reportFilename); if (!quiet && latexOutput && resourceBundle != null) { log.info(commandOutput + "\n"); } // A second execution is required for building the document index. commandOutput = extCommand.runCommand(command + " " + reportFilename); // if (!quiet && latexOutput && resourceBundle != null) { // log.info(commandOutput + "\n"); // } // Add this at the end to avoid mixing with the latex command // output. if (resourceBundle != null) { String pdfFile = filesLocation + File.separator + FilenameUtils.removeExtension(reportFilename) + ".pdf"; if (new File(pdfFile).exists()) log.info("\t" + pdfFile); else { log.error("\t" + pdfFile + " FAILED"); throw new FileNotFoundException("Error: File not created!"); } } cleanPDFLatexOutput(); }
From source file:org.ballerinalang.ballerina.openapi.convertor.service.OpenApiConverterUtils.java
private static String getOpenApiFileName(Path servicePath, String serviceName) { Path file = servicePath.getFileName(); String openApiFile;/* w w w. j a v a 2 s . com*/ if (StringUtils.isNotBlank(serviceName)) { openApiFile = serviceName + ConverterConstants.OPENAPI_SUFFIX; } else { openApiFile = file != null ? FilenameUtils.removeExtension(file.toString()) + ConverterConstants.OPENAPI_SUFFIX : null; } return openApiFile + ConverterConstants.YAML_EXTENSION; }
From source file:org.ballerinalang.ballerina.swagger.convertor.service.SwaggerConverterUtils.java
private static String getSwaggerFileName(Path servicePath, String serviceName) { Path file = servicePath.getFileName(); String swaggerFile;/*from w w w .j a v a2 s . c om*/ if (StringUtils.isNotBlank(serviceName)) { swaggerFile = serviceName + ConverterConstants.SWAGGER_SUFFIX; } else { swaggerFile = file != null ? FilenameUtils.removeExtension(file.toString()) + ConverterConstants.SWAGGER_SUFFIX : null; } return swaggerFile + ConverterConstants.YAML_EXTENSION; }
From source file:org.ballerinalang.composer.service.workspace.rest.datamodel.BLangFragmentParserTest.java
private static void loadSamples(List<String[]> fragments, String type) throws IOException { File samples = new File(CLASS_LOADER.getResource(SAMPLES_DIR + type).getFile()); if (samples.isDirectory()) { for (File sample : samples.listFiles()) { if (sample.isFile()) { String nameWithoutExt = FilenameUtils.removeExtension(sample.getName()); File expected = new File(CLASS_LOADER .getResource(SAMPLES_DIR + type + "/expected/" + nameWithoutExt + ".json").getFile()); if (expected.isFile()) { fragments.add(new String[] { type, nameWithoutExt, sample.getPath(), expected.getPath() }); }// w w w . j a v a 2 s . c o m } } } }
From source file:org.ballerinalang.langserver.command.executors.CreateTestExecutor.java
public static String generateTestFileName(Path sourceFilePath) { String fileName = FilenameUtils.removeExtension(sourceFilePath.toFile().getName()); return fileName + "_test" + ProjectDirConstants.BLANG_SOURCE_EXT; }
From source file:org.bibalex.gallery.model.BAGAlbum.java
public BAGAlbum(BAGGalleryAbstract gallery, String name) throws BAGException { super();//from w ww. j a v a2s. co m this.gallery = gallery; this.name = name; this.thumbnails = new LinkedList<BAGThumbnail>(); this.iamgeNamesByIx = new HashMap<Integer, String>(); this.imageIxesByName = new HashMap<String, Integer>(); String thumbsUrl = this.gallery.getAlbumHttpAccUrlStr(this.name, EnumResolutions.thumb); int ix = 0; for (String filename : BAGStorage.listChildren(thumbsUrl, FileType.FILE)) { String imageName = FilenameUtils.removeExtension(filename); String urlStr = this.gallery.getThumbLocalUrl(this.name, imageName); BAGThumbnail thumb = new BAGThumbnail(imageName, imageName, urlStr); this.thumbnails.add(thumb); Integer ixObj = Integer.valueOf(ix); this.iamgeNamesByIx.put(ixObj, imageName); this.imageIxesByName.put(imageName, ixObj); ix++; } this.imagesCount = this.thumbnails.size(); }
From source file:org.bigtester.ate.model.caserunner.CaseRunnerGenerator.java
/** * Creates the case runners./*from w ww . j a v a 2 s. c om*/ * * @throws ParseException * the parse exception * @throws IOException * Signals that an I/O exception has occurred. */ public void createCaseRunners() throws ParseException, IOException { // creates an input stream for the file to be parsed for (TestSuite tSuite : suites) { File suiteCacheDir = new File(caseRunnerCacheAbsoluteFolder + tSuite.getSuiteName() + "/"); if (!suiteCacheDir.exists()) { suiteCacheDir.mkdirs(); } for (int index = 0; index < tSuite.getTestCaseList().size(); index++) { Resource fTemp = new ClassPathResource(caseRunnerTemplateFileName); CompilationUnit caseRunnerCU; caseRunnerCU = JavaParser.parse(fTemp.getInputStream()); this.basePackageName = caseRunnerCU.getPackage().getName().toStringWithoutComments(); try { File newCaseRunner = File.createTempFile("CaseRunner", ".java", suiteCacheDir); this.caseRunnerJavaFileNames.put(tSuite.getTestCaseList().get(index).getTestCaseFilePathName(), newCaseRunner.getCanonicalPath()); new TestCaseNameFieldVisitor().visit(caseRunnerCU, tSuite.getTestCaseList().get(index).getTestCaseFilePathName()); new ClassNameVisitor().visit(caseRunnerCU, FilenameUtils.removeExtension(newCaseRunner.getName())); new PackageNameVisitor().visit(caseRunnerCU, this.basePackageName + "." + tSuite.getSuiteName()); new MethodTestAnnotationVisitor().visit(caseRunnerCU, tSuite.getTestCaseList().get(index)); // prints the changed compilation unit PrintWriter out = new PrintWriter(newCaseRunner); out.println(caseRunnerCU.toString()); out.close(); } catch (IOException ioE) { continue; } fTemp.getInputStream().close(); } } }
From source file:org.bigtester.ate.model.caserunner.CaseRunnerGenerator.java
private String parseClassFullName(String caseRunnerJavaFilePathName) { String packageName = parsePackageName(caseRunnerJavaFilePathName); String caseRunnerFileName = new File(caseRunnerJavaFilePathName).getName(); return packageName + "." + FilenameUtils.removeExtension(caseRunnerFileName); }
From source file:org.broad.igv.goby.GobyCountArchiveDataSource.java
private void init(String filename) { try {//from w w w . j a v a 2 s . com this.filename = FilenameUtils.removeExtension(filename); counts = new CachingCountsArchiveReader(this.filename); ids = counts.getIdentifiers(); for (String id : ids) { if (id.startsWith("chr")) { someIdsStartWithChr = true; break; } } if (counts.isStatsParsed()) { this.numBasesSeen = counts.getTotalBasesSeen(); this.numSitesSeen = counts.getTotalSitesSeen(); hasPrecomputedStats = true; } boolean normalizeCounts = PreferenceManager.getInstance() .getAsBoolean(PreferenceManager.NORMALIZE_COVERAGE); setNormalize(normalizeCounts); } catch (IOException ex) { LOG.error("Error loading file: " + filename, ex); throw new DataLoadException("Error loading goby counts archive file: " + ex.toString(), filename); } }
From source file:org.bsc.maven.plugin.findclass.ClasspathDescriptor.java
private void addArchive(final File element) throws IOException { if (addCached(element)) { return;//from ww w . j a v a 2s . c om } final List<String> classes = new ArrayList<>(); final List<String> resources = new ArrayList<>(); InputStream input = null; ZipInputStream zipInput = null; try { input = element.toURI().toURL().openStream(); zipInput = new ZipInputStream(input); ZipEntry entry; while ((entry = zipInput.getNextEntry()) != null) { if (!entry.isDirectory()) { final String name = entry.getName(); if ("class".equals(FilenameUtils.getExtension(name))) { final String className = FilenameUtils.removeExtension(name).replace('/', '.').replace('\\', '.'); classes.add(className); addClass(className, element); } else { final String resourcePath = name.replace('\\', File.separatorChar); resources.add(resourcePath); addResource(resourcePath, element); } } } CACHED_BY_ELEMENT.put(element, new Cached(classes, resources)); } finally { if (zipInput != null) { // this will also close the wrapped stream IOUtils.closeQuietly(zipInput); } else if (input != null) { IOUtils.closeQuietly(input); } } }