本文整理匯總了Java中org.apache.commons.io.FilenameUtils.getBaseName方法的典型用法代碼示例。如果您正苦於以下問題:Java FilenameUtils.getBaseName方法的具體用法?Java FilenameUtils.getBaseName怎麽用?Java FilenameUtils.getBaseName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.io.FilenameUtils
的用法示例。
在下文中一共展示了FilenameUtils.getBaseName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: buildURI
import org.apache.commons.io.FilenameUtils; //導入方法依賴的package包/類
private String buildURI(final File sourceFile) {
String uri = FileUtil.asPath(sourceFile.getPath()).replace(FileUtil.asPath( contentPath), "");
boolean noExtensionUri = config.getBoolean(Keys.URI_NO_EXTENSION);
String noExtensionUriPrefix = config.getString(Keys.URI_NO_EXTENSION_PREFIX);
if (noExtensionUri && noExtensionUriPrefix != null && noExtensionUriPrefix.length() > 0) {
// convert URI from xxx.html to xxx/index.html
if (uri.startsWith(noExtensionUriPrefix)) {
uri = "/" + FilenameUtils.getPath(uri) + FilenameUtils.getBaseName(uri) + "/index" + config.getString(Keys.OUTPUT_EXTENSION);
}
} else {
uri = uri.substring(0, uri.lastIndexOf(".")) + config.getString(Keys.OUTPUT_EXTENSION);
}
// strip off leading / to enable generating non-root based sites
if (uri.startsWith("/")) {
uri = uri.substring(1, uri.length());
}
return uri;
}
示例2: JavaSerializationPeakClusterRead
import org.apache.commons.io.FilenameUtils; //導入方法依賴的package包/類
private boolean JavaSerializationPeakClusterRead() {
if (!new File(FilenameUtils.getFullPath(ParentmzXMLName) + FilenameUtils.getBaseName(ParentmzXMLName) + "_Peak/" + FilenameUtils.getBaseName(ScanCollectionName) + "_PeakCluster.ser").exists()) {
return false;
}
try {
Logger.getRootLogger().info("Reading PeakCluster serialization from file:" + FilenameUtils.getBaseName(ScanCollectionName) + "_PeakCluster.ser...");
FileInputStream fileIn = new FileInputStream(FilenameUtils.getFullPath(ParentmzXMLName) + FilenameUtils.getBaseName(ParentmzXMLName) + "_Peak/" + FilenameUtils.getBaseName(ScanCollectionName) + "_PeakCluster.ser");
ObjectInputStream in = new ObjectInputStream(fileIn);
PeakClusters = (ArrayList<PeakCluster>) in.readObject();
in.close();
fileIn.close();
} catch (Exception ex) {
Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex));
return false;
}
return true;
}
示例3: FasterSerialzationRead
import org.apache.commons.io.FilenameUtils; //導入方法依賴的package包/類
public static FastaParser FasterSerialzationRead(String Filename) throws FileNotFoundException {
if (!new File(FilenameUtils.getFullPath(Filename) + FilenameUtils.getBaseName(Filename) + ".FastaSer").exists()) {
return null;
}
FastaParser fastareader = null;
try {
org.apache.log4j.Logger.getRootLogger().info("Loading fasta serialization to file:" + FilenameUtils.getFullPath(Filename) + FilenameUtils.getBaseName(Filename) + ".FastaSer..");
FileInputStream fileIn = new FileInputStream(FilenameUtils.getFullPath(Filename) + FilenameUtils.getBaseName(Filename) + ".FastaSer");
FSTObjectInput in = new FSTObjectInput(fileIn);
fastareader = (FastaParser) in.readObject();
in.close();
fileIn.close();
} catch (Exception ex) {
org.apache.log4j.Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex));
return null;
}
return fastareader;
}
示例4: getOutputFile
import org.apache.commons.io.FilenameUtils; //導入方法依賴的package包/類
private static File getOutputFile(String extension) {
outputFilename = args.HasOption("output-file") ?
args.GetOption("output-file") :
FilenameUtils.getBaseName(args.GetOption("access-file")) + "." + extension;
File outFile = new File(FilenameUtils.concat(FilenameUtils.getFullPath(args.GetOption("access-file")), outputFilename));
if(outFile.exists()) {
try {
outFile.delete();
} catch(SecurityException e) {
Error(String.format("Could not delete existing output file '%s'", outputFilename));
return null;
}
}
return outFile;
}
示例5: createSuffixUrl
import org.apache.commons.io.FilenameUtils; //導入方法依賴的package包/類
private String createSuffixUrl(String inputUrl, String suffix) {
String outputUrl = "";
if(suffix.equals(STREAM)) {
if (inputUrl.endsWith(VIDEO_EXTENSION)) {
String name = FilenameUtils.getBaseName(inputUrl);
String outName = name.replace(VIDEO_EXTENSION, "");
outName = outName + '/' + STREAM;
outputUrl = inputUrl.replace(name + VIDEO_EXTENSION, outName);
}
} else {
if (inputUrl.endsWith(VIDEO_EXTENSION)) {
outputUrl = inputUrl.replace(VIDEO_EXTENSION, suffix + VIDEO_EXTENSION);
}
}
return outputUrl;
}
示例6: ReadParametersSerialization
import org.apache.commons.io.FilenameUtils; //導入方法依賴的package包/類
public static InstrumentParameter ReadParametersSerialization(String filepath) {
if (!new File(FilenameUtils.getFullPath(filepath) + FilenameUtils.getBaseName(filepath) + "_params.ser").exists()) {
return null;
}
try {
Logger.getRootLogger().info("Reading parameters from file:" + FilenameUtils.getFullPath(filepath) + FilenameUtils.getBaseName(filepath) + "_params.ser...");
FileInputStream fileIn = new FileInputStream(FilenameUtils.getFullPath(filepath) + FilenameUtils.getBaseName(filepath) + "_params.ser");
ObjectInputStream in = new ObjectInputStream(fileIn);
InstrumentParameter params = (InstrumentParameter) in.readObject();
in.close();
fileIn.close();
return params;
} catch (Exception ex) {
Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex));
return null;
}
}
示例7: FSCluster2CurveRead
import org.apache.commons.io.FilenameUtils; //導入方法依賴的package包/類
private boolean FSCluster2CurveRead() {
if (!new File(FilenameUtils.getFullPath(ParentmzXMLName) + FilenameUtils.getBaseName(ParentmzXMLName) + "_Peak/" + FilenameUtils.getBaseName(ScanCollectionName) + "_Clus2Cur.serFS").exists()) {
return false;
}
try {
Logger.getRootLogger().debug("Reading PrecursorFragmentCorr serialization from file:" + FilenameUtils.getBaseName(ScanCollectionName) + "_Clus2Cur.serFS...");
FileInputStream fileIn = new FileInputStream(FilenameUtils.getFullPath(ParentmzXMLName) + FilenameUtils.getBaseName(ParentmzXMLName) + "_Peak/" + FilenameUtils.getBaseName(ScanCollectionName) + "_Clus2Cur.serFS");
FSTObjectInput in = new FSTObjectInput(fileIn);
FragmentsClu2Cur = (HashMap<Integer, ArrayList<PrecursorFragmentPairEdge>>) in.readObject();
in.close();
fileIn.close();
} catch (Exception ex) {
Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex));
return false;
}
return true;
}
示例8: FS_PeakClusterRead
import org.apache.commons.io.FilenameUtils; //導入方法依賴的package包/類
private boolean FS_PeakClusterRead() {
if (!new File(FilenameUtils.getFullPath(ParentmzXMLName) + FilenameUtils.getBaseName(ParentmzXMLName) + "_Peak/" + FilenameUtils.getBaseName(ScanCollectionName) + "_PeakCluster.serFS").exists()) {
return false;
}
try {
Logger.getRootLogger().info("Reading PeakCluster serialization from file:" + FilenameUtils.getBaseName(ScanCollectionName) + "_PeakCluster.serFS...");
FileInputStream fileIn = new FileInputStream(FilenameUtils.getFullPath(ParentmzXMLName) + FilenameUtils.getBaseName(ParentmzXMLName) + "_Peak/" + FilenameUtils.getBaseName(ScanCollectionName) + "_PeakCluster.serFS");
FSTObjectInput in = new FSTObjectInput(fileIn);
PeakClusters = (ArrayList<PeakCluster>) in.readObject();
in.close();
fileIn.close();
} catch (Exception ex) {
Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex));
if (FS_PeakClusterRead_Old()) {
WritePeakClusterSerialization();
return true;
}
Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex));
return false;
}
return true;
}
示例9: FS_PeakClusterWrite
import org.apache.commons.io.FilenameUtils; //導入方法依賴的package包/類
private void FS_PeakClusterWrite() {
try {
Logger.getRootLogger().info("Writing PeakCluster serialization to file:" + FilenameUtils.getBaseName(ScanCollectionName) + "_PeakCluster.serFS...");
FileOutputStream fout = new FileOutputStream(FilenameUtils.getFullPath(ParentmzXMLName) + FilenameUtils.getBaseName(ParentmzXMLName) + "_Peak/" + FilenameUtils.getBaseName(ScanCollectionName) + "_PeakCluster.serFS", false);
FSTObjectOutput out = new FSTObjectOutput(fout);
out.writeObject(PeakClusters);
out.close();
fout.close();
} catch (Exception ex) {
Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex));
JavaSerializationPeakClusterWrite();
}
}
示例10: FSCluster2CurveUnfragWrite
import org.apache.commons.io.FilenameUtils; //導入方法依賴的package包/類
private void FSCluster2CurveUnfragWrite() {
try {
Logger.getRootLogger().debug("Writing UnfragPrecursorFragCorr serialization to file:" + FilenameUtils.getBaseName(ScanCollectionName) + "_UnfClus2Cur.serFS...");
FileOutputStream fout = new FileOutputStream(FilenameUtils.getFullPath(ParentmzXMLName) + FilenameUtils.getBaseName(ParentmzXMLName) + "_Peak/" + FilenameUtils.getBaseName(ScanCollectionName) + "_UnfClus2Cur.serFS", false);
FSTObjectOutput oos = new FSTObjectOutput(fout);
oos.writeObject(UnFragIonClu2Cur);
oos.close();
fout.close();
} catch (Exception ex) {
Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex));
}
}
示例11: saveParsedText
import org.apache.commons.io.FilenameUtils; //導入方法依賴的package包/類
@Override
public File saveParsedText(String path, File file, String text) {
String filename = FilenameUtils.getBaseName(file.getName()) + EXTENSION;
createDirectory(CommonUtils.TMP_FILES_PATH);
String tmpFile = String.join(CommonUtils.DELIMITER, path, filename);
try {
FileWriter fileWriter = new FileWriter(tmpFile);
fileWriter.write(text);
fileWriter.flush();
fileWriter.close();
} catch (IOException e) {
e.printStackTrace();
}
return new File(tmpFile);
}
示例12: ExportPepPSMCSV
import org.apache.commons.io.FilenameUtils; //導入方法依賴的package包/類
private void ExportPepPSMCSV(String folder) throws IOException {
if (folder == null | "".equals(folder)) {
folder = FilenameUtils.getFullPath(mzXMLFileName);
}
Logger.getRootLogger().info("Writing PSM result to file:" + folder + FilenameUtils.getBaseName(mzXMLFileName) + "_PSMs.csv...");
FileWriter writer = new FileWriter(folder + FilenameUtils.getBaseName(mzXMLFileName) + "_PSMs.csv");
writer.write("SpecID,Sequence,ModSeq,TPPModSeq,Modification,Charge,mz,NeutralPepMass,ObservedMass,RT,AdjustedRT,Rank,ScanNo,PreAA,NextAA,MissedCleavage,ExpectValue,MassError,Prob,Rawname,ParentPepIndex,MS1Quant\n");
for (PepIonID pepion : PepIonList.values()) {
for (PSM psm : pepion.GetPSMList()) {
writer.write(psm.SpecNumber + "," + psm.Sequence + "," + psm.ModSeq + "," + psm.TPPModSeq + "," + psm.GetModificationString() + "," + psm.Charge + "," + psm.ObserPrecursorMz() + "," + psm.NeutralPepMass + "," + psm.ObserPrecursorMass + "," + psm.RetentionTime + "," + psm.NeighborMaxRetentionTime + "," + psm.Rank + "," + psm.ScanNo + "," + psm.PreAA + "," + psm.NextAA + "," + psm.MissedCleavage + "," + psm.expect + "," + psm.MassError + "," + psm.Probability + "," + psm.RawDataName + "," + pepion.Index + "," + pepion.GetMS1() + "\n");
}
}
writer.close();
}
示例13: handlePost
import org.apache.commons.io.FilenameUtils; //導入方法依賴的package包/類
@RequestMapping(method = RequestMethod.POST)
protected String handlePost(RedirectAttributes redirectAttributes,
HttpServletRequest request
) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
try {
if (ServletFileUpload.isMultipartContent(request)) {
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
List<?> items = upload.parseRequest(request);
for (Object o : items) {
FileItem item = (FileItem) o;
if ("file".equals(item.getFieldName()) && !StringUtils.isBlank(item.getName())) {
if (item.getSize() > MAX_PLAYLIST_SIZE_MB * 1024L * 1024L) {
throw new Exception("The playlist file is too large. Max file size is " + MAX_PLAYLIST_SIZE_MB + " MB.");
}
String playlistName = FilenameUtils.getBaseName(item.getName());
String fileName = FilenameUtils.getName(item.getName());
String format = StringUtils.lowerCase(FilenameUtils.getExtension(item.getName()));
String username = securityService.getCurrentUsername(request);
Playlist playlist = playlistService.importPlaylist(username, playlistName, fileName,
item.getInputStream(), null);
map.put("playlist", playlist);
}
}
}
} catch (Exception e) {
map.put("error", e.getMessage());
}
redirectAttributes.addFlashAttribute("model", map);
return "redirect:importPlaylist";
}
示例14: generateChannelApk
import org.apache.commons.io.FilenameUtils; //導入方法依賴的package包/類
private void generateChannelApk(final File inputFile, final File outputDir, final String channel, final String alias, final Map<String, String> extraInfo) {
final String channelName = alias == null ? channel : alias;
final String name = FilenameUtils.getBaseName(inputFile.getName());
final String extension = FilenameUtils.getExtension(inputFile.getName());
final String newName = name + "_" + channelName + "." + extension;
final File channelApk = new File(outputDir, newName);
try {
FileUtils.copyFile(inputFile, channelApk);
ChannelWriter.put(channelApk, channel, extraInfo);
} catch (IOException | SignatureNotFoundException e) {
e.printStackTrace();
}
}
示例15: LibraryMatchWrite
import org.apache.commons.io.FilenameUtils; //導入方法依賴的package包/類
public boolean LibraryMatchWrite() throws FileNotFoundException {
try {
Logger.getRootLogger().info("Writing Target match results to file:" + FilenameUtils.getFullPath(Filename) + FilenameUtils.getBaseName(Filename) + "_" + LibID + "_LibMatch.serFS...");
FileOutputStream fout = new FileOutputStream(FilenameUtils.getFullPath(Filename) + FilenameUtils.getBaseName(Filename) + "_" + LibID + "_LibMatch.serFS", false);
FSTObjectOutput out = new FSTObjectOutput(fout);
out.writeObject(this);
out.close();
fout.close();
} catch (Exception ex) {
Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex));
return false;
}
return true;
}