List of usage examples for org.apache.commons.io IOCase INSENSITIVE
IOCase INSENSITIVE
To view the source code for org.apache.commons.io IOCase INSENSITIVE.
Click Source Link
From source file:com.github.aliteralmind.codelet.examples.util.BlackWhiteListForJavaClasses.java
public static final void main(String[] ignored) { FilenameBlacklist blackList = new FilenameBlacklist(IOCase.INSENSITIVE, //Propers: (new String[] { "xbn.io.*", "xbn.text.*" }), //Overrides: (new String[] { "xbn.text.line.*", "xbn.io.IOUtil.java" }), null); //Debugging. on=System.out, off=null System.out.println(blackList.doAccept("xbn.io.IOUtil.java")); System.out.println(blackList.doAccept("xbn.io.TextAppenter.java")); System.out.println(blackList.doAccept("xbn.list.listify.Listify")); System.out.println(blackList.doAccept("xbn.text.UtilString.java")); System.out.println(blackList.doAccept("xbn.text.line.LineFilter.java")); System.out.println();/*from ww w. j a va 2s .c o m*/ FilenameWhitelist whiteList = new FilenameWhitelist(blackList, IOCase.INSENSITIVE, null); //Debugging. On=System.out, off=null System.out.println(whiteList.doAccept("xbn.io.IOUtil.java")); System.out.println(whiteList.doAccept("xbn.io.TextAppenter.java")); System.out.println(whiteList.doAccept("xbn.list.listify.Listify")); System.out.println(whiteList.doAccept("xbn.text.UtilString.java")); System.out.println(whiteList.doAccept("xbn.text.line.LineFilter.java")); }
From source file:acmi.l2.clientmod.l2_version_switcher.Main.java
public static void main(String[] args) { if (args.length != 3 && args.length != 4) { System.out.println("USAGE: l2_version_switcher.jar host game version <--splash> <filter>"); System.out.println("EXAMPLE: l2_version_switcher.jar " + L2.NCWEST_HOST + " " + L2.NCWEST_GAME + " 1 \"system\\*\""); System.out.println(//from w w w. j av a 2 s . co m " l2_version_switcher.jar " + L2.PLAYNC_TEST_HOST + " " + L2.PLAYNC_TEST_GAME + " 48"); System.exit(0); } List<String> argsList = new ArrayList<>(Arrays.asList(args)); String host = argsList.get(0); String game = argsList.get(1); int version = Integer.parseInt(argsList.get(2)); Helper helper = new Helper(host, game, version); boolean available = false; try { available = helper.isAvailable(); } catch (IOException e) { System.err.print(e.getClass().getSimpleName()); if (e.getMessage() != null) { System.err.print(": " + e.getMessage()); } System.err.println(); } System.out.println(String.format("Version %d available: %b", version, available)); if (!available) { System.exit(0); } List<FileInfo> fileInfoList = null; try { fileInfoList = helper.getFileInfoList(); } catch (IOException e) { System.err.println("Couldn\'t get file info map"); System.exit(1); } boolean splash = argsList.remove("--splash"); if (splash) { Optional<FileInfo> splashObj = fileInfoList.stream() .filter(fi -> fi.getPath().contains("sp_32b_01.bmp")).findAny(); if (splashObj.isPresent()) { try (InputStream is = new FilterInputStream( Util.getUnzipStream(helper.getDownloadStream(splashObj.get().getPath()))) { @Override public int read() throws IOException { int b = super.read(); if (b >= 0) b ^= 0x36; return b; } @Override public int read(byte[] b, int off, int len) throws IOException { int r = super.read(b, off, len); if (r >= 0) { for (int i = 0; i < r; i++) b[off + i] ^= 0x36; } return r; } }) { new DataInputStream(is).readFully(new byte[28]); BufferedImage bi = ImageIO.read(is); JFrame frame = new JFrame("Lineage 2 [" + version + "] " + splashObj.get().getPath()); frame.setContentPane(new JComponent() { { setPreferredSize(new Dimension(bi.getWidth(), bi.getHeight())); } @Override protected void paintComponent(Graphics g) { g.drawImage(bi, 0, 0, null); } }); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } catch (IOException e) { e.printStackTrace(); } } else { System.out.println("Splash not found"); } return; } String filter = argsList.size() > 3 ? separatorsToSystem(argsList.get(3)) : null; File l2Folder = new File(System.getProperty("user.dir")); List<FileInfo> toUpdate = fileInfoList.parallelStream().filter(fi -> { String filePath = separatorsToSystem(fi.getPath()); if (filter != null && !wildcardMatch(filePath, filter, IOCase.INSENSITIVE)) return false; File file = new File(l2Folder, filePath); try { if (file.exists() && file.length() == fi.getSize() && Util.hashEquals(file, fi.getHash())) { System.out.println(filePath + ": OK"); return false; } } catch (IOException e) { System.out.println(filePath + ": couldn't check hash: " + e); return true; } System.out.println(filePath + ": need update"); return true; }).collect(Collectors.toList()); List<String> errors = Collections.synchronizedList(new ArrayList<>()); ExecutorService executor = Executors.newFixedThreadPool(16); CompletableFuture[] tasks = toUpdate.stream().map(fi -> CompletableFuture.runAsync(() -> { String filePath = separatorsToSystem(fi.getPath()); File file = new File(l2Folder, filePath); File folder = file.getParentFile(); if (!folder.exists()) { if (!folder.mkdirs()) { errors.add(filePath + ": couldn't create parent dir"); return; } } try (InputStream input = Util .getUnzipStream(new BufferedInputStream(helper.getDownloadStream(fi.getPath()))); OutputStream output = new BufferedOutputStream(new FileOutputStream(file))) { byte[] buffer = new byte[Math.min(fi.getSize(), 1 << 24)]; int pos = 0; int r; while ((r = input.read(buffer, pos, buffer.length - pos)) >= 0) { pos += r; if (pos == buffer.length) { output.write(buffer, 0, pos); pos = 0; } } if (pos != 0) { output.write(buffer, 0, pos); } System.out.println(filePath + ": OK"); } catch (IOException e) { String msg = filePath + ": FAIL: " + e.getClass().getSimpleName(); if (e.getMessage() != null) { msg += ": " + e.getMessage(); } errors.add(msg); } }, executor)).toArray(CompletableFuture[]::new); CompletableFuture.allOf(tasks).thenRun(() -> { for (String err : errors) System.err.println(err); executor.shutdown(); }); }
From source file:com.tekstosense.opennlp.config.ModelLoaderConfig.java
/** * Gets the models./*from w w w .j av a2 s . co m*/ * * @return the models */ public static String[] getModels() { File dir = new File(Config.getConfiguration().getString(MODELPATH)); LOG.info("Loading Models from... " + dir.getAbsolutePath()); List<String> models = new ArrayList<>(); String[] modelNames = getModelNames(); List<String> wildCardPath = Arrays.stream(modelNames).map(model -> { return "en-ner-" + model + "*.bin"; }).collect(Collectors.toList()); FileFilter fileFilter = new WildcardFileFilter(wildCardPath, IOCase.INSENSITIVE); List<String> filePath = Arrays.asList(dir.listFiles(fileFilter)).stream() .map(file -> file.getAbsolutePath()).collect(Collectors.toList()); return filePath.toArray(new String[filePath.size()]); }
From source file:net.sf.jvifm.model.filter.PathFilter.java
public boolean accept(File file) { String path = file.getPath(); if (FilenameUtils.wildcardMatch(path, wildcard, IOCase.INSENSITIVE)) { return true; }/* www .j ava 2 s . c o m*/ return false; }
From source file:br.msf.maven.compressor.processor.CssCompressor.java
@Override public boolean accept(final File inputFile) { return IOUtils.isFile(inputFile) && (new WildcardFileFilter(CSS_WILDCARDS, IOCase.INSENSITIVE)).accept(inputFile); }
From source file:it.geosolutions.tools.io.CollectorTests.java
@Test public final void testCollect() throws Exception { Collector c = new Collector(FileFilterUtils.or(new WildcardFileFilter("*_PCK.xml", IOCase.INSENSITIVE), new WildcardFileFilter("*_PRO", IOCase.INSENSITIVE))); File location = TestData.file(this, "collector"); LOGGER.info("Location: " + location.getAbsoluteFile()); assertNotNull(location);/*from w w w . j a va 2 s .c o m*/ assertTrue(location.exists()); List<File> list = c.collect(location); assertNotNull(list); LOGGER.info("Number of files..." + list.size()); for (File f : list) { LOGGER.info("FILE: " + f.getAbsolutePath()); } assertEquals("Wrong number of files...", FILES_IN_TEST, list.size()); }
From source file:br.msf.maven.compressor.processor.JavaScriptCompressor.java
@Override public boolean accept(final File inputFile) { return inputFile != null && inputFile.isFile() && (new WildcardFileFilter(JAVASCRIPT_WILDCARDS, IOCase.INSENSITIVE)).accept(inputFile); }
From source file:com.tekstosense.opennlp.config.ModelLoaderConfig.java
public static String[] getModels(String[] modelNames) { File dir = new File(Config.getConfiguration().getString(MODELPATH)); LOG.info("Loading Models from... " + dir.getAbsolutePath()); List<String> wildCardPath = Arrays.stream(modelNames).map(model -> { return "en-ner-" + model + "*.bin"; }).collect(Collectors.toList()); FileFilter fileFilter = new WildcardFileFilter(wildCardPath, IOCase.INSENSITIVE); List<String> filePath = Arrays.asList(dir.listFiles(fileFilter)).stream() .map(file -> file.getAbsolutePath()).collect(Collectors.toList()); return filePath.toArray(new String[filePath.size()]); }
From source file:com.mucommander.commons.file.filter.WildcardFileFilter.java
/** * Creates a new <code>WildcardFileFilter</code> operating in the specified mode. * * @param s the wildcard to match// w w w.j ava 2 s . co m * @param caseSensitive if true, this FilenameFilter will be case-sensitive * @param inverted if true, this filter will operate in inverted mode. */ public WildcardFileFilter(String s, boolean caseSensitive, boolean inverted) { super(new FilenameGenerator(), caseSensitive, inverted); this.fileFilter = new org.apache.commons.io.filefilter.WildcardFileFilter(s, isCaseSensitive() ? IOCase.SENSITIVE : IOCase.INSENSITIVE); }
From source file:com.stratelia.webactiv.util.fileFolder.FileFolderManager.java
/** * Returns all the files (and only the files, no directory) inside the given directory. * @param chemin//ww w .j av a 2 s . c om * @return * @throws UtilException */ public static Collection<File> getAllFile(String chemin) throws UtilException { List<File> resultat = new ArrayList<File>(); File directory = new File(chemin); if (directory.isDirectory()) { resultat = new ArrayList<File>(FileUtils.listFiles(directory, null, false)); Collections.sort(resultat, new NameFileComparator(IOCase.INSENSITIVE)); } else { SilverTrace.error("util", "FileFolderManager.getAllFile", "util.EX_NO_CHEMIN_REPOS", chemin); throw new UtilException("FileFolderManager.getAllFile", "util.EX_NO_CHEMIN_REPOS", chemin); } return resultat; }