List of usage examples for org.apache.commons.io.filefilter FileFileFilter FILE
IOFileFilter FILE
To view the source code for org.apache.commons.io.filefilter FileFileFilter FILE.
Click Source Link
From source file:ViewImageTest.java
/** * Test image(s) (default : JPEG_example_JPG_RIP_100.jpg) are parsed and * rendered to an output foler. Result can then be checked with program of * your choice./*from ww w . ja va 2 s. c om*/ * * @param args * may be empty or contain parameters to override defaults : * <ul> * <li>args[0] : input image file URL or folder containing image * files URL. Default : * viewImageTest/test/JPEG_example_JPG_RIP_100.jpg</li> * <li>args[1] : output format name (for example : "jpg") for * rendered image</li> * <li>args[2] : ouput folder URL</li> * <li>args[3] : max width (in pixels) for rendered image. * Default : no value.</li> * <li>args[4] : max height (in pixels) for rendered image. * Default : no value.</li> * </ul> * @throws IOException * when a read/write error occured */ public static void main(String args[]) throws IOException { File inURL = getInputURL(args); String ext = getEncodingExt(args); File outDir = getOuputDir(args); serverObjects post = makePostParams(args); outDir.mkdirs(); File[] inFiles; if (inURL.isFile()) { inFiles = new File[1]; inFiles[0] = inURL; System.out.println("Testing ViewImage rendering with input file : " + inURL.getAbsolutePath() + " encoded To : " + ext); } else if (inURL.isDirectory()) { FileFilter filter = FileFileFilter.FILE; inFiles = inURL.listFiles(filter); System.out.println("Testing ViewImage rendering with input files in folder : " + inURL.getAbsolutePath() + " encoded To : " + ext); } else { inFiles = new File[0]; } if (inFiles.length == 0) { throw new IllegalArgumentException(inURL.getAbsolutePath() + " is not a valid file or folder url."); } System.out.println("Rendered images will be written in dir : " + outDir.getAbsolutePath()); Map<String, Exception> failures = new HashMap<String, Exception>(); try { for (File inFile : inFiles) { /* Delete eventual previous result file */ File outFile = new File(outDir, inFile.getName() + "." + ext); if (outFile.exists()) { outFile.delete(); } byte[] resourceb = getBytes(inFile); String urlString = inFile.getAbsolutePath(); EncodedImage img = null; Exception error = null; try { img = ViewImage.parseAndScale(post, true, urlString, ext, false, resourceb); } catch (Exception e) { error = e; } if (img == null) { failures.put(urlString, error); } else { FileOutputStream outFileStream = null; try { outFileStream = new FileOutputStream(outFile); img.getImage().writeTo(outFileStream); } finally { if (outFileStream != null) { outFileStream.close(); } img.getImage().close(); } } } displayResults(inFiles, failures); } finally { ConcurrentLog.shutdown(); } }
From source file:com.qwazr.search.index.BackupStatus.java
final static BackupStatus newBackupStatus(File backupDir) { if (backupDir == null) return null; try {// w w w .j a v a2 s .c o m long generation = Long.parseLong(backupDir.getName()); File[] files = backupDir.listFiles((FileFilter) FileFileFilter.FILE); long bytes_size = 0; if (files == null) return null; for (File file : files) bytes_size += file.length(); return new BackupStatus(generation, backupDir.lastModified(), bytes_size, files.length); } catch (NumberFormatException e) { return null; } }
From source file:com.qwazr.library.test.AbstractLibraryTest.java
protected void before() throws IOException { final LibraryManager libraryManager = LibraryManager.getInstance(); if (libraryManager != null) return;// w w w.j a va2 s. co m TrackedDirectory etcTracker = new TrackedDirectory(new File("src/test/resources/etc"), FileFileFilter.FILE); LibraryManager.load(new File("src/test/resources"), etcTracker); etcTracker.check(); }
From source file:com.uksf.mf.core.utility.LogHandler.java
/** * First checks if there are already 10 log files, if so, deletes the oldest, then creates the new log file *//*from ww w. j a v a 2 s . co m*/ private void createLogFile() { if (LOG_CREATED) return; LOGS.mkdir(); File[] logs = LOGS.listFiles((FileFilter) FileFileFilter.FILE); assert logs != null; if (logs.length > 1) Arrays.sort(logs, LastModifiedFileComparator.LASTMODIFIED_COMPARATOR); if (logs.length > 9) { if (!logs[0].delete()) { System.out.println("'" + logs[0].getAbsolutePath() + logs[0].getName() + "' was not deleted."); } } logFile = new File(LOGS + "\\MF__" + DATEFORMAT.format(DATE) + ".log"); try { if (!logFile.createNewFile()) { throw new IOException("Log file not created at '" + logFile.getAbsolutePath() + "'"); } } catch (IOException e) { error(e); } System.out.println(logFile.getAbsolutePath()); LOG_CREATED = true; logSeverity(INFO, "Log Created"); }
From source file:com.liferay.maven.plugins.SassToCssBuilderMojo.java
protected void doExecute() throws Exception { FileFilter fileFilter = FileFilterUtils.orFileFilter(DirectoryFileFilter.DIRECTORY, FileFilterUtils.andFileFilter(FileFileFilter.FILE, FileFilterUtils.suffixFileFilter(".css"))); FileUtils.copyDirectory(webappSourceDir, webappDir, fileFilter, true); if (Validator.isNull(sassPortalCommonDir)) { File file = new File(appServerPortalDir, "html/css/common"); sassPortalCommonDir = file.getAbsolutePath(); }/* w ww. jav a 2 s . com*/ String[] args = null; String[] dirNames = StringUtil.split(sassDirNames); if (dirNames.length > 1) { if (getPortalMajorVersion() < PORTAL_VERSION_6_2) { args = new String[dirNames.length]; } else { args = new String[dirNames.length + 2]; args[dirNames.length] = "sass.docroot.dir=" + sassDocrootDir; args[dirNames.length + 1] = "sass.portal.common.dir=" + sassPortalCommonDir; } for (int i = 0; i < dirNames.length; i++) { if (getPortalMajorVersion() < PORTAL_VERSION_6_2) { args[i] = "sass.dir." + i + "=" + dirNames[i]; } } } else { if (getPortalMajorVersion() < PORTAL_VERSION_6_2) { if (sassDirNames.equals("/")) { sassDirNames = ""; } args = new String[] { "sass.dir=" + sassDocrootDir + sassDirNames }; } else { args = new String[] { "sass.dir=" + sassDirNames, "sass.docroot.dir=" + sassDocrootDir, "sass.portal.common.dir=" + sassPortalCommonDir }; } } executeTool("com.liferay.portal.tools.SassToCssBuilder", getProjectClassLoader(), args); }
From source file:com.github.jarscanner.DirectoryScanner.java
public List<File> scanFiles(String dirName) throws IOException { List<File> result = new ArrayList<File>(); File file = new File(dirName); LOG.info("Scan folder - " + dirName); String addDirName = StringUtils.remove(file.getAbsolutePath().replace("\\", "/"), dirName).replaceFirst(".", "");// www . java2 s . co m if (file.isDirectory()) { Collection<File> filesInDir = FileUtils.listFiles(file, FileFileFilter.FILE, null); if (!filesInDir.isEmpty()) { for (File file2 : filesInDir) { result.add(file2); } } } return result; }
From source file:gobblin.aws.GobblinAWSUtils.java
private static String getClasspathFromPath(File path) { if (null == path) { return StringUtils.EMPTY; }/*from w w w . jav a 2s . c o m*/ if (!path.isDirectory()) { return path.getAbsolutePath(); } return Joiner.on(":").skipNulls().join(path.list(FileFileFilter.FILE)); }
From source file:com.qwazr.QwazrConfiguration.java
private static FileFilter buildEtcFileFilter(String etc) { if (StringUtils.isEmpty(etc)) return FileFileFilter.FILE; String[] array = StringUtils.split(etc, ','); if (array == null || array.length == 0) return FileFileFilter.FILE; return new AndFileFilter(FileFileFilter.FILE, new WildcardFileFilter(array)); }
From source file:com.commander4j.thread.InboundMessageCollectionThread.java
private LinkedList<String> getInputFilename(String inputPath) { LinkedList<String> Result = new LinkedList<String>(); File dir;//w ww .j a v a2 s .c om dir = new File(inputPath); chld = dir.listFiles((FileFilter) FileFileFilter.FILE); if (chld == null) { logger.debug("Specified directory does not exist or is not a directory. [" + inputPath + "]"); } else { Arrays.sort(chld, LastModifiedFileComparator.LASTMODIFIED_COMPARATOR); for (int i = 0; i < chld.length; i++) { fileName = chld[i].getName(); if (fileName.toLowerCase().endsWith(".xml")) { Result.addLast(fileName); } } } return Result; }
From source file:com.qwazr.QwazrConfiguration.java
private static FileFilter buildEtcFileFilter(Collection<String> etcs) { if (etcs == null || etcs.isEmpty()) return FileFileFilter.FILE; return new AndFileFilter(FileFileFilter.FILE, new WildcardFileFilter(etcs.toArray(new String[etcs.size()]))); }