List of usage examples for org.apache.commons.io FilenameUtils getBaseName
public static String getBaseName(String filename)
From source file:ching.icecreaming.actions.FileLink.java
@Action(value = "file-link", results = { @Result(name = "success", type = "stream", params = { "inputName", "imageStream", "contentType", "${contentType}", "contentDisposition", "attachment;filename=${fileName}", "allowCaching", "false", "bufferSize", "1024" }), @Result(name = "error", location = "errors.jsp") }) public String execute() throws Exception { Configuration propertiesConfiguration1 = new PropertiesConfiguration("mimeTypes.properties"); File file1 = null, file2 = null; String string1 = null, fileExtension = null; fileExtension = FilenameUtils.getExtension(fileName); contentType = "application/octet-stream"; if (!StringUtils.isBlank(fileExtension)) { if (propertiesConfiguration1.containsKey(fileExtension)) contentType = propertiesConfiguration1.getString(fileExtension); } else {//ww w .j a v a 2 s.co m contentType = "image/png"; } try { if (StringUtils.isBlank(sessionId)) { sessionId = httpServletRequest.getSession().getId(); } string1 = System.getProperty("java.io.tmpdir") + File.separator + sessionId; if (StringUtils.isBlank(fileExtension)) string1 += File.separator + FilenameUtils.getPath(fileName); fileName = FilenameUtils.getName(fileName); if (StringUtils.equalsIgnoreCase(fileExtension, "html")) { file2 = new File(string1, FilenameUtils.getBaseName(fileName) + ".zip"); if (file2.exists()) { file1 = file2; contentType = "application/zip"; fileName = file2.getName(); } else { file1 = new File(string1, fileName); } } else { file1 = new File(string1, fileName); } if (file1.exists()) { imageStream = new BufferedInputStream(FileUtils.openInputStream(file1)); } } catch (IOException exception1) { addActionError(exception1.getMessage()); return ERROR; } return SUCCESS; }
From source file:integr.org.pgptool.gui.encryption.EncryptionDecryptionTests.java
@Test public void testWeCanDecryptTheProductOfEncryptionUsingCreatedKey() throws Exception { Key key = keyGeneratorService.createNewKey(KeyRingServiceTest.buildTestKey()); List keys = Arrays.asList(key); String targetFilename = tempDirPath + File.separator + FilenameUtils.getBaseName(testSubjectFilename) + ".pgp"; encryptionService.encrypt(testSubjectFilename, targetFilename, keys, null, null, null); String decryptionKeyId = (String) encryptionService.findKeyIdsForDecryption(targetFilename).iterator() .next();//from w w w.j ava 2 s .c om PasswordDeterminedForKey keyAndPassword = new PasswordDeterminedForKey(decryptionKeyId, key, "pass"); encryptionService.decrypt(targetFilename, targetFilename + ".test", keyAndPassword, null, null); String result = TextFile.read(targetFilename + ".test"); assertEquals(testSubjectContents, result); }
From source file:com.epam.catgenome.manager.maf.MafManager.java
private MafFile downloadMafFile(IndexedFileRegistrationRequest request, String requestPath) throws IOException, NoSuchAlgorithmException { MafFile mafFile;// w ww . j a va 2 s.co m final File newFile = downloadFileManager.downloadFromURL(requestPath); request.setIndexPath(null); request.setName(request.getName() != null ? request.getName() : FilenameUtils.getBaseName(requestPath)); request.setPath(newFile.getPath()); mafFile = registerMafFileFromFile(request); return mafFile; }
From source file:edu.ku.brc.af.core.db.BackupServiceFactory.java
/** * @param restoreName/*from ww w.j a va 2 s. c om*/ * @return */ protected String getStatsName(final String restoreName) { String baseFileName = FilenameUtils.getBaseName(restoreName); String path = FilenameUtils.getFullPath(restoreName); return FilenameUtils.concat(path, baseFileName + ".stats"); }
From source file:MSUmpire.DIA.RTAlignedPepIonMapping.java
public void GenerateMappedPepIon() { Logger.getRootLogger().info(/*from w ww. j ava 2 s. c o m*/ "Mapping predicted peptide ions for " + FilenameUtils.getBaseName(LCMSB.mzXMLFileName) + "..."); if (!regression.valid()) { return; } for (PepIonID pepion : LCMSA.GetPepIonList().values()) { PepIonID predictedPepIon = null; if (!LCMSB.GetPepIonList().containsKey(pepion.GetKey())) { if (LCMSB.GetMappedPepIonList().containsKey(pepion.GetKey())) { predictedPepIon = LCMSB.GetMappedPepIonList().get(pepion.GetKey()); } else { predictedPepIon = pepion.ClonePepIonID(); LCMSB.GetMappedPepIonList().put(pepion.GetKey(), predictedPepIon); } } else { predictedPepIon = LCMSB.GetPepIonList().get(pepion.GetKey()); } XYZData predict = regression.GetPredictTimeSDYByTimelist(pepion.GetIDRT()); float PRT = predict.getY(); boolean added = true; for (float rt : predictedPepIon.PredictRT) { if (Math.abs(PRT - rt) < 0.1f) { added = false; } } if (added) { predictedPepIon.PredictRT.add(PRT); } predictedPepIon.SetRTSD(predict.getZ()); } Logger.getRootLogger().info( "Mapping predicted peptide ions for " + FilenameUtils.getBaseName(LCMSA.mzXMLFileName) + "..."); for (PepIonID pepion : LCMSB.GetPepIonList().values()) { PepIonID predictedPepIon = null; if (!LCMSA.GetPepIonList().containsKey(pepion.GetKey())) { if (LCMSA.GetMappedPepIonList().containsKey(pepion.GetKey())) { predictedPepIon = LCMSA.GetMappedPepIonList().get(pepion.GetKey()); } else { predictedPepIon = pepion.ClonePepIonID(); LCMSA.GetMappedPepIonList().put(pepion.GetKey(), predictedPepIon); } } else { predictedPepIon = LCMSA.GetPepIonList().get(pepion.GetKey()); } XYZData predict = regression.GetPredictTimeSDXByTimelist(pepion.GetIDRT()); float PRT = predict.getY(); boolean added = true; for (float rt : predictedPepIon.PredictRT) { if (Math.abs(PRT - rt) < 0.1f) { added = false; } } if (added) { predictedPepIon.PredictRT.add(PRT); } predictedPepIon.SetRTSD(predict.getZ()); } }
From source file:edu.fullerton.ldvplugin.WplotManager.java
private String getDescription(File file) { String desc = FilenameUtils.getBaseName(file.getName()) + "<br>"; return desc; }
From source file:com.frostwire.gui.library.DownloadTask.java
private File buildFile(File savePath, String name) { String baseName = FilenameUtils.getBaseName(name); String ext = FilenameUtils.getExtension(name); File f = new File(savePath, name); int i = 1;/*from w w w . ja v a 2 s. c o m*/ while (f.exists() && i < 100) { f = new File(savePath, baseName + " (" + i + ")." + ext); i++; } return f; }
From source file:eu.udig.style.advanced.common.StyleManager.java
/** * Exports a style to file taking care of external graphics. * /* ww w. j a v a 2s . c o m*/ * <p>This copies the graphics to the file and puts relative paths in the sld.</p> * * @param styleWrapper the style to dump * @param file the file of the resource that need the sld (for ex. a shapefile). * @throws Exception */ public void exportStyle(StyleWrapper styleWrapper, File file) throws Exception { File parentFolder = file.getParentFile(); String baseName = FilenameUtils.getBaseName(file.getAbsolutePath()); int index = 1; List<FeatureTypeStyleWrapper> featureTypeStylesWrapperList = styleWrapper.getFeatureTypeStylesWrapperList(); for (FeatureTypeStyleWrapper featureTypeStyleWrapper : featureTypeStylesWrapperList) { List<RuleWrapper> rulesWrapperList = featureTypeStyleWrapper.getRulesWrapperList(); for (RuleWrapper ruleWrapper : rulesWrapperList) { SymbolizerWrapper symbolizersWrapper = ruleWrapper.getGeometrySymbolizersWrapper(); String externalGraphicPath = symbolizersWrapper.getExternalGraphicPath(); if (externalGraphicPath != null && externalGraphicPath.length() > 0) { File graphicsFile = new File(externalGraphicPath); String extension = FilenameUtils.getExtension(graphicsFile.getName()); String newImageName = baseName + "_" + index + "." + extension; //$NON-NLS-1$ //$NON-NLS-2$ index++; File newFile = new File(parentFolder, newImageName); FileUtils.copyFile(graphicsFile, newFile); symbolizersWrapper.setExternalGraphicPath(newFile.getAbsolutePath()); } } } String styleString = styleWrapper.toXml(); File newFile = new File(parentFolder, baseName + SLD_EXTENTION); FileUtils.writeStringToFile(newFile, styleString); }
From source file:fr.inria.soctrace.tools.importer.moca.core.MocaParser.java
private void saveTraceMetadata(MocaTraceType aTraceType) throws SoCTraceException { String alias = FilenameUtils.getBaseName(traceDB.get(aTraceType).getDBName()); MocaTraceMetadata metadata = new MocaTraceMetadata(sysDB, traceDB.get(aTraceType).getDBName(), alias, numberOfEvents);/*from w w w . ja v a 2 s . c o m*/ metadata.createMetadata(); metadata.saveMetadata(); sysDB.commit(); }
From source file:com.frostwire.gui.UniversalScanner.java
private void scanAudio(String filePath, boolean shared) { File file = new File(filePath); ContentValues values = new ContentValues(); String mime = "audio/" + FilenameUtils.getExtension(filePath); fillCommonValues(values, Constants.FILE_TYPE_AUDIO, filePath, file, mime, shared); try {//from ww w . jav a 2s . c o m TagsData mt = new TagsReader(file).parse(); values.put(Columns.TITLE, mt.getTitle()); values.put(Columns.ARTIST, mt.getArtist()); values.put(Columns.ALBUM, mt.getAlbum()); values.put(Columns.YEAR, mt.getYear()); } catch (Throwable e) { String displayName = FilenameUtils.getBaseName(file.getName()); values.put(Columns.TITLE, displayName); values.put(Columns.ARTIST, ""); values.put(Columns.ALBUM, ""); values.put(Columns.YEAR, ""); } ShareFilesDB db = ShareFilesDB.intance(); db.insert(values); }