List of usage examples for org.apache.commons.io FilenameUtils isExtension
public static boolean isExtension(String filename, Collection<String> extensions)
From source file:gobblin.hive.avro.HiveAvroSchemaManager.java
@SuppressWarnings("deprecation") private Schema getSchema(Path path) { try {/* ww w .j a va 2s .c o m*/ for (FileStatus status : this.fs.listStatus(path)) { if (status.isDir()) { Schema schema = getSchema(status.getPath()); if (schema != null) { return schema; } } else if (FilenameUtils.isExtension(status.getPath().getName().toLowerCase(), AVRO)) { return AvroUtils.getSchemaFromDataFile(status.getPath(), this.fs); } } return null; } catch (IOException e) { log.error("Unable to get schema from " + path, e); throw Throwables.propagate(e); } }
From source file:com.jaxio.celerio.convention.CommentStyle.java
public static CommentStyle fromFilename(String filename) { for (CommentStyle style : values()) { if (FilenameUtils.isExtension(filename, style.getExtensions())) { return style; }// ww w .j ava2s . c o m } return null; }
From source file:com.iyonger.apm.web.handler.GroovyMavenProjectScriptHandler.java
@Override public boolean canHandle(FileEntry fileEntry) { if (fileEntry.getCreatedUser() == null) { return false; }//from ww w. j a v a 2 s. c om String path = fileEntry.getPath(); if (!FilenameUtils.isExtension(path, "groovy")) { return false; } //noinspection SimplifiableIfStatement if (!path.contains(JAVA) && !path.contains(GROOVY)) { return false; } return getFileEntryRepository().hasOne(fileEntry.getCreatedUser(), getBasePath(path) + "/pom.xml"); }
From source file:com.jaeksoft.searchlib.learning.LearnerManager.java
public LearnerManager(Client client, File directory) throws XPathExpressionException, SearchLibException, ParserConfigurationException, SAXException, IOException { this.client = client; learnerArray = null;//from ww w . j a va 2s . com activeLearnerArray = null; learnerMap = new TreeMap<String, Learner>(); for (File f : directory.listFiles()) if (f.isFile()) { String fname = f.getName(); if (!FilenameUtils.isExtension(fname, "xml")) continue; if (fname.endsWith("_old.xml")) continue; if (fname.endsWith("_tmp.xml")) continue; add(new Learner(client, f)); } }
From source file:io.github.swagger2markup.extensions.DynamicContentExtension.java
/** * Builds extension sections/*from w w w . jav a2 s.c o m*/ * * @param extensionMarkupLanguage the MarkupLanguage of the snippets content * @param contentPath the path where the content files reside * @param prefix extension file prefix * @param levelOffset import markup level offset */ public void extensionsSection(MarkupLanguage extensionMarkupLanguage, Path contentPath, final String prefix, int levelOffset) { final Collection<String> filenameExtensions = globalContext.getConfig().getMarkupLanguage() .getFileNameExtensions().stream().map(fileExtension -> StringUtils.stripStart(fileExtension, ".")) .collect(Collectors.toList()); DirectoryStream.Filter<Path> filter = entry -> { String fileName = entry.getFileName().toString(); return fileName.startsWith(prefix) && FilenameUtils.isExtension(fileName, filenameExtensions); }; try (DirectoryStream<Path> extensionFiles = Files.newDirectoryStream(contentPath, filter)) { if (extensionFiles != null) { List<Path> extensions = Lists.newArrayList(extensionFiles); Collections.sort(extensions, Ordering.natural()); for (Path extension : extensions) { importContent(extension, (reader) -> contentContext.getMarkupDocBuilder().importMarkup(reader, extensionMarkupLanguage, levelOffset)); } } } catch (IOException e) { if (logger.isDebugEnabled()) logger.debug("Failed to read extension files from directory {}", contentPath); } }
From source file:com.jaeksoft.searchlib.classifier.ClassifierManager.java
public ClassifierManager(Client client, File directory) throws XPathExpressionException, SearchLibException, ParserConfigurationException, SAXException, IOException { this.client = client; classifierArray = null;/*from w w w .j a v a 2 s . c o m*/ activeClassifierArray = null; classifierSet = new TreeSet<Classifier>(); for (File f : directory.listFiles()) if (f.isFile()) { String fname = f.getName(); if (!FilenameUtils.isExtension(fname, "xml")) continue; if (fname.endsWith("_old.xml")) continue; if (fname.endsWith("_tmp.xml")) continue; add(new Classifier(f)); } }
From source file:com.moki.touch.util.UrlUtil.java
/** * This method determines if the url passed in is the location of a video that we can download * @param url a valid url to a video/*from ww w . j av a 2s .co m*/ * @return true for valid video urls or false */ public static boolean isContentVideo(String url) { boolean isVideo; if (isCachebleVimeoLink(url)) { isVideo = true; } else { isVideo = FilenameUtils.isExtension(url, videoExtentions); } return isVideo; }
From source file:com.mirth.connect.client.ui.components.ChannelTableTransferHandler.java
@Override public boolean importData(TransferSupport support) { if (canImport(support)) { try {/* w w w . jav a2 s . co m*/ if (support.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { List<File> fileList = (List<File>) support.getTransferable() .getTransferData(DataFlavor.javaFileListFlavor); final boolean showAlerts = (fileList.size() == 1); // Submit each import task to a single-threaded executor so they always import one at a time. Executor executor = Executors.newSingleThreadExecutor(); for (final File file : fileList) { if (FilenameUtils.isExtension(file.getName(), "xml")) { executor.execute(new Runnable() { @Override public void run() { importFile(file, showAlerts); } }); } } return true; } else if (support.isDataFlavorSupported(ChannelTableTransferable.CHANNEL_DATA_FLAVOR)) { List<Object> list = (List<Object>) support.getTransferable() .getTransferData(ChannelTableTransferable.CHANNEL_DATA_FLAVOR); List<Channel> channels = new ArrayList<Channel>(); for (Object obj : list) { if (obj instanceof Channel) { channels.add((Channel) obj); } else { return false; } } if (support.getDropLocation() instanceof JTable.DropLocation) { return moveChannels(channels, ((JTable.DropLocation) support.getDropLocation()).getRow()); } } } catch (Exception e) { // Let it return false } } return false; }
From source file:com.mirth.connect.client.ui.components.MirthTableTransferHandler.java
@Override public boolean importData(TransferSupport support) { if (canImport(support)) { try {// ww w .j a va 2 s .c o m List<File> fileList = (List<File>) support.getTransferable() .getTransferData(DataFlavor.javaFileListFlavor); boolean showAlerts = (fileList.size() == 1); for (File file : fileList) { if (FilenameUtils.isExtension(file.getName(), "xml")) { importFile(file, showAlerts); } } return true; } catch (Exception e) { // Let it return false } } return false; }
From source file:ch.ifocusit.livingdoc.plugin.PublishMojo.java
/** * @return html pages//from w w w. j a v a2 s . c om * @throws IOException */ private List<Page> readHtmlPages() throws IOException { List<Page> pages = new ArrayList<>(); Files.walk(Paths.get(generatedDocsDirectory.getAbsolutePath())) .filter(path -> FilenameUtils.isExtension(path.getFileName().toString(), new String[] { Format.adoc.name(), Format.asciidoc.name(), Format.html.name() })) .forEach(path -> { try { Map<String, String> attachmentCollector = new HashMap<>(); HtmlPostProcessor htmlProcessor = getPostProcessor(); Page page = new Page(); page.setSpaceKey(publish.getSpaceKey()); page.setParentId(publish.getAncestorId()); page.setTitle(htmlProcessor.getPageTitle(path)); page.setFile(path); String content = htmlProcessor.process(path, attachmentCollector); page.setContent(content); attachmentCollector.forEach(page::addAttachement); pages.add(page); } catch (IOException e) { throw new IllegalArgumentException("error reading file", e); } }); return pages; }