List of usage examples for org.apache.commons.io FilenameUtils getName
public static String getName(String filename)
From source file:cu.uci.uengine.runner.impl.FileRunner.java
private String buildCommand(String language, String filePath, String directoryPath) { String command = executionCommands.get(language); command = command.replace("<EXE>", FilenameUtils.getName(filePath)); command = command.replace("<EXEDIR>", directoryPath); command = command.replace("<EXEPATH>", filePath); return command; }
From source file:br.univali.celine.lms.utils.zip.Zip.java
public void zip(ArrayList<String> fileList, File destFile, int compressionLevel) throws Exception { if (destFile.exists()) throw new Exception("File " + destFile.getName() + " already exists!!"); int fileLength; byte[] buffer = new byte[4096]; FileOutputStream fos = new FileOutputStream(destFile); BufferedOutputStream bos = new BufferedOutputStream(fos); ZipOutputStream zipFile = new ZipOutputStream(bos); zipFile.setLevel(compressionLevel);/*from www.ja va 2 s . c om*/ for (int i = 0; i < fileList.size(); i++) { FileInputStream fis = new FileInputStream(fileList.get(i)); BufferedInputStream bis = new BufferedInputStream(fis); ZipEntry ze = new ZipEntry(FilenameUtils.getName(fileList.get(i))); zipFile.putNextEntry(ze); while ((fileLength = bis.read(buffer, 0, 4096)) > 0) zipFile.write(buffer, 0, fileLength); zipFile.closeEntry(); bis.close(); } zipFile.close(); }
From source file:ch.cyberduck.cli.GlobTransferItemFinder.java
@Override public Set<TransferItem> find(final CommandLine input, final TerminalAction action, final Path remote) throws AccessDeniedException { if (input.getOptionValues(action.name()).length == 2) { final String path = input.getOptionValues(action.name())[1]; // This only applies to a shell where the glob is not already expanded into multiple arguments if (StringUtils.containsAny(path, '*', '?')) { final Local directory = LocalFactory.get(FilenameUtils.getFullPath(path)); if (directory.isDirectory()) { final PathMatcher matcher = FileSystems.getDefault() .getPathMatcher(String.format("glob:%s", FilenameUtils.getName(path))); final Set<TransferItem> items = new HashSet<TransferItem>(); for (Local file : directory.list(new NullFilter<String>() { @Override/* ww w . java 2 s .co m*/ public boolean accept(final String file) { try { return matcher.matches(Paths.get(file)); } catch (InvalidPathException e) { log.warn(String.format("Failure obtaining path for file %s", file)); } return false; } })) { items.add(new TransferItem(new Path(remote, file.getName(), EnumSet.of(Path.Type.file)), file)); } return items; } } } return new SingleTransferItemFinder().find(input, action, remote); }
From source file:de.sanandrew.mods.turretmod.registry.assembly.TurretAssemblyRecipes.java
private static boolean processRecipeJson(Path file, final ITurretAssemblyRegistry registry) { return FilenameUtils.getName(file.toString()).startsWith("group_") || processJson(file, json -> registerJsonRecipes(json, registry)); }
From source file:net.grinder.util.AbstractGrinderClassPathProcessor.java
/** * Construct classPath for grinder from given classpath string. * * @param classPath classpath string// w w w.ja v a 2 s.c o m * @param logger logger * @return classpath optimized for grinder. */ public String filterClassPath(String classPath, Logger logger) { List<String> classPathList = new ArrayList<String>(); for (String eachClassPath : checkNotNull(classPath).split(File.pathSeparator)) { String filename = FilenameUtils.getName(eachClassPath); if (isUsefulJar(filename) || isUsefulReferenceProject(eachClassPath)) { logger.trace("classpath :" + eachClassPath); classPathList.add(eachClassPath); } } return StringUtils.join(classPathList, File.pathSeparator); }
From source file:hudson.plugins.msbuild.MsBuildKillingVeto.java
/** * *//*from w w w . ja va 2s . co m*/ @Override public VetoCause vetoProcessKilling(IOSProcess proc) { if (proc == null) return null; List<String> cmdLine = proc.getArguments(); if (cmdLine == null || cmdLine.isEmpty()) return null; String command = cmdLine.get(0); String exeName = FilenameUtils.getName(command); if (exeName.toLowerCase().equals("mspdbsrv.exe")) { return VETO_CAUSE; } return null; }
From source file:i.am.jiongxuan.deapk.Deapk.java
public Deapk(String apkPath) { mApkDir = new File(apkPath); String apkName = FilenameUtils.getName(apkPath); String projectName = apkName.substring(0, apkName.lastIndexOf('.')); mProjectDir = new File(mApkDir.getParentFile(), projectName + "_project"); mClassesDexFile = new File(mProjectDir, "classes.dex"); mClassesJarFile = new File(mProjectDir, "classes.jar"); mClassesJarErrorFile = new File(mProjectDir, "classes-error.zip"); mErrorFile = new File(mProjectDir, "error.txt"); mSrcDir = new File(mProjectDir, "src"); mSmaliDir = new File(mProjectDir, "smali"); mGenerateProjectOperator = new GenerateProjectOperator(mProjectDir); }
From source file:com.impetus.ankush.agent.utils.ZipFiles.java
/** * Zip file.//from www.j a v a 2 s . c om * * @param filePath the file path * @return the string */ public String zipFile(String filePath) { try { /* Create Output Stream that will have final zip files */ OutputStream zipOutput = new FileOutputStream(new File(filePath + ".zip")); /* * Create Archive Output Stream that attaches File Output Stream / and * specifies type of compression */ ArchiveOutputStream logicalZip = new ArchiveStreamFactory() .createArchiveOutputStream(ArchiveStreamFactory.ZIP, zipOutput); /* Create Archieve entry - write header information */ logicalZip.putArchiveEntry(new ZipArchiveEntry(FilenameUtils.getName(filePath))); /* Copy input file */ IOUtils.copy(new FileInputStream(new File(filePath)), logicalZip); /* Close Archieve entry, write trailer information */ logicalZip.closeArchiveEntry(); /* Finish addition of entries to the file */ logicalZip.finish(); /* Close output stream, our files are zipped */ zipOutput.close(); } catch (Exception e) { System.err.println(e.getMessage()); return null; } return filePath + ".zip"; }
From source file:com.frostwire.search.eztv.EztvSearchResult.java
public EztvSearchResult(String detailsUrl, SearchMatcher matcher) { this.detailsUrl = detailsUrl; String dispName = null;/*from w ww . j a v a 2 s . co m*/ if (matcher.group("displayname") != null) { dispName = matcher.group("displayname"); } else if (matcher.group("displayname2") != null) { dispName = matcher.group("displayname2"); } else if (matcher.group("displaynamefallback") != null) { dispName = matcher.group("displaynamefallback"); } this.displayName = HtmlManipulator.replaceHtmlEntities(dispName).trim(); this.torrentUrl = buildTorrentUrl(matcher); this.filename = parseFileName(FilenameUtils.getName(torrentUrl)); this.infoHash = parseInfoHash(matcher, torrentUrl); this.seeds = parseSeeds(matcher.group("seeds")); this.creationTime = parseCreationTime(matcher.group("creationtime")); this.size = parseSize(matcher.group("filesize")); }
From source file:net.grinder.util.GrinderClassPathUtils.java
/** * Construct the classpath of ngrinder which is very important and located in the head of * classpath./*from www .ja va2s . co m*/ * * @param classPath * classpath string * @param logger * logger * @return classpath optimized for grinder. */ public static String filterPatchClassPath(String classPath, Logger logger) { List<String> classPathList = new ArrayList<String>(); for (String eachClassPath : checkNotNull(classPath).split(File.pathSeparator)) { String filename = FilenameUtils.getName(eachClassPath); if (isPatchJar(filename)) { logger.trace("classpath :" + eachClassPath); classPathList.add(eachClassPath); } } return StringUtils.join(classPathList, File.pathSeparator); }