List of usage examples for org.apache.commons.io FilenameUtils getName
public static String getName(String filename)
From source file:com.sisrni.managedbean.EditorImages.java
public void uploadListener(FileUploadEvent event) { FacesContext facesContext = FacesContext.getCurrentInstance(); ExternalContext externalContext = facesContext.getExternalContext(); HttpServletResponse response = (HttpServletResponse) externalContext.getResponse(); String fileName = FilenameUtils.getName(event.getFile().getFileName()); String fileNamePrefix = FilenameUtils.getBaseName(fileName) + "_"; String fileNameSuffix = "." + FilenameUtils.getExtension(fileName); File uploadFolder = new File("/var/webapp/uploads"); try {/*from ww w . j a v a 2s . c o m*/ File result = File.createTempFile(fileNamePrefix, fileNameSuffix, uploadFolder); FileOutputStream fileOutputStream = new FileOutputStream(result); byte[] buffer = new byte[1024]; int bulk; InputStream inputStream = event.getFile().getInputstream(); while (true) { bulk = inputStream.read(buffer); if (bulk < 0) { break; } fileOutputStream.write(buffer, 0, bulk); fileOutputStream.flush(); } fileOutputStream.close(); inputStream.close(); String value = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap() .get("editor_input"); setText(value + "<img src=\"/rais/uploads/" + result.getName() + "\" />"); RequestContext.getCurrentInstance().update("editor_input"); FacesMessage msg = new FacesMessage("Succesful", event.getFile().getFileName() + " is uploaded."); FacesContext.getCurrentInstance().addMessage(null, msg); } catch (IOException e) { e.printStackTrace(); FacesMessage error = new FacesMessage("The files were not uploaded!"); FacesContext.getCurrentInstance().addMessage(null, error); } }
From source file:com.frostwire.android.gui.transfers.TorrentUrlInfo.java
@Override public String getDisplayName() { return (displayName == null || displayName.isEmpty()) ? FilenameUtils.getName(url) : displayName; }
From source file:net.grinder.util.GrinderClassPathUtils.java
/** * Construct the classpath of ngrinder which is very important and located in the head of * classpath./* w ww .java2 s .c o m*/ * * @param classPath * classpath string * @param logger * logger * @return classpath optimized for grinder. */ public static String filterForeMostClassPath(String classPath, Logger logger) { List<String> classPathList = new ArrayList<String>(); for (String eachClassPath : checkNotNull(classPath).split(File.pathSeparator)) { String filename = FilenameUtils.getName(eachClassPath); if (isForeMostJar(filename)) { logger.trace("classpath :" + eachClassPath); classPathList.add(eachClassPath); } } return StringUtils.join(classPathList, File.pathSeparator); }
From source file:com.frostwire.search.archiveorg.ArchiveorgCrawledSearchResult.java
public ArchiveorgCrawledSearchResult(ArchiveorgSearchResult sr, ArchiveorgFile file) { super(sr);//from w ww.j a va 2s . c om this.filename = FilenameUtils.getName(file.filename); this.displayName = FilenameUtils.getBaseName(filename) + " (" + sr.getDisplayName() + ")"; this.downloadUrl = String.format(Locale.US, DOWNLOAD_URL, sr.getDomainName(), sr.getIdentifier(), UrlUtils.encode(file.filename)); this.size = calcSize(file); }
From source file:com.haulmont.cuba.web.gui.components.WebClasspathResource.java
@Override protected void createResource() { String name = StringUtils.isNotEmpty(fileName) ? fileName : FilenameUtils.getName(path); resource = new StreamResource(() -> AppBeans.get(Resources.class).getResourceAsStream(path), name); StreamResource streamResource = (StreamResource) this.resource; streamResource.setMIMEType(mimeType); streamResource.setCacheTime(cacheTime); streamResource.setBufferSize(bufferSize); }
From source file:com.opendesign.utils.ControllerUtil.java
public static boolean isImageFile(HttpServletRequest request, String filePathOnWebBase, String fileDomain) { String fileUploadDir = CmnUtil.getFileUploadDir(request, fileDomain); //String fileName = filePathOnWebBase.substring(filePathOnWebBase.lastIndexOf(File.separator) ); String fileName = File.separator + FilenameUtils.getName(filePathOnWebBase); File file = new File(fileUploadDir + fileName); return ThumbnailManager.isImageFile(file); }
From source file:FeatureExtraction.FeatureExtractorOOXMLStructuralPathsDisk.java
@Override public Map<String, Integer> ExtractFeaturesFrequencyFromSingleElement(T element) { Map<String, Integer> structuralPaths = new HashMap<>(); String filePath = (String) element; String destinationFolder = FileUtils.getTempDirectoryPath() + FilenameUtils.getName(filePath); m_OfficeFileTempFolderPath = destinationFolder + "\\"; if (UnzipFileToFolder(filePath, destinationFolder)) { ExtractFolderStructuralPaths(destinationFolder, structuralPaths); }/* w w w. j av a2 s . c o m*/ //Directories.DeleteDirectory(destinationFolder); //TODO return structuralPaths; }
From source file:com.frostwire.frostclick.TorrentPromotionSearchResult.java
@Override public String getFilename() { return FilenameUtils.getName(slide.torrent); }
From source file:com.frostwire.android.gui.transfers.DesktopTransferItem.java
DesktopTransferItem(FileDescriptor fd) { this.fd = fd; this.savePath = new File(SystemUtils.getDesktopFilesirectory(), FilenameUtils.getName(fd.filePath)); }
From source file:com.frostwire.search.torrent.TorrentCrawledSearchResult.java
public TorrentCrawledSearchResult(TorrentCrawlableSearchResult sr, TorrentInfo ti, int fileIndex, String filePath, long fileSize) { super(sr);// w w w . j ava2 s. c o m this.ti = ti; this.fileIndex = fileIndex; this.filePath = filePath; this.filename = FilenameUtils.getName(this.filePath); this.size = fileSize; this.displayName = FilenameUtils.getBaseName(this.filename); }