List of usage examples for java.io File isHidden
public boolean isHidden()
From source file:org.saiku.service.importer.impl.LegacyImporterImpl.java
public void importSchema() { setPath("res:legacy-schema"); try {/*from w w w. j ava 2 s.co m*/ if (repoURL != null) { File[] files = new File(repoURL.getFile()).listFiles(); if (files != null) { for (File file : files) { if (!file.isHidden() && !file.getName().equals("README")) { byte[] encoded = null; try { encoded = org.apache.commons.io.IOUtils.toByteArray(new FileInputStream(file)); } catch (IOException e1) { e1.printStackTrace(); } String str = null; if (encoded != null) { str = new String(encoded, Charset.forName("UTF8")); } dsm.addSchema(str, "/datasources/" + file.getName(), "admin"); } } } } } catch (Exception e1) { e1.printStackTrace(); } }
From source file:org.knime.ext.textprocessing.nodes.source.parser.tika.TikaParserNodeModel.java
private boolean filterLocalFiles(final URL s) { try {// w w w . j av a2 s . com final File file = FileUtil.getFileFromURL(s); if (file != null) { if (m_ignoreHiddenFilesModel.getBooleanValue() && file.isHidden()) { return false; } if (!file.isFile() || file.isDirectory()) { return false; } } } catch (Exception e) { return false; } return true; }
From source file:org.saiku.web.rest.resources.BasicRepositoryResource.java
/** * Get Saved Queries.//from w w w . ja va 2s . co m * @return A list of SavedQuery Objects. */ @GET @Produces({ "application/json" }) public List<SavedQuery> getSavedQueries() { List<SavedQuery> queries = new ArrayList<SavedQuery>(); try { if (repo != null) { File[] files = new File(repo.getName().getPath()).listFiles(); for (File file : files) { if (!file.isHidden()) { SimpleDateFormat sf = new SimpleDateFormat("dd - MMM - yyyy HH:mm:ss"); String filename = file.getName(); if (filename.endsWith(".saiku")) { filename = filename.substring(0, filename.length() - ".saiku".length()); FileReader fi = new FileReader(file); BufferedReader br = new BufferedReader(fi); String chunk = "", xml = ""; while ((chunk = br.readLine()) != null) { xml += chunk + "\n"; } SavedQuery sq = new SavedQuery(filename, sf.format(new Date(file.lastModified())), xml); queries.add(sq); } } } } else { throw new Exception("repo URL is null"); } } catch (Exception e) { log.error(this.getClass().getName(), e); e.printStackTrace(); } Collections.sort(queries); return queries; }
From source file:com.all.rds.loader.util.PlaylistReader.java
public PlaylistReader(File playlistDir) { playlist = new TopPlaylist(playlistDir.getName()); tracks = new ArrayList<File>(); for (File file : FileUtil.listAudioFiles(playlistDir, false)) { if (!file.isHidden()) { tracks.add(file);/*from w ww .j av a 2 s. c o m*/ } } Collections.sort(tracks, FILE_NAME_COMPARATOR); }
From source file:org.atomserver.blogs.FileBasedBlogService.java
public List<String> listCollections(String workspace) { List<String> collections = new ArrayList<String>(); for (File file : getRootDir().listFiles(new FileFilter() { public boolean accept(File pathname) { return pathname.exists() && pathname.isDirectory() && pathname.canRead() && pathname.canWrite() && !pathname.isHidden(); }// www. j a v a 2 s.co m })) { collections.add(file.getName()); } return collections; }
From source file:org.sakaiproject.content.chh.file.ContentCollectionFileSystem.java
public int getMemberCount() { int count = 0; String[] contents = file.list(); if (contents == null) return 0; // directory doesn't exist any more for (int x = 0; x < contents.length; ++x) { File f = new File(contents[x]); if (showHiddenFiles || (!contents[x].startsWith(".") && !f.isHidden())) count++;//w ww . j a va2 s . c o m } return count; }
From source file:org.saiku.adhoc.providers.impl.standalone.StandalonePrptProvider.java
public void load() { datasources.clear();// w w w. java 2 s.c o m try { if (repoURL != null) { File[] files = new File(repoURL.getFile()).listFiles(); for (File file : files) { if (!file.isHidden()) { if (getFileExtension(file.getAbsolutePath()) != null && getFileExtension(file.getAbsolutePath()).equalsIgnoreCase("prpt")) { // Properties props = new Properties(); // props.load(new FileInputStream(file)); // String name = props.getProperty("name"); // String type = props.getProperty("type"); // if (name != null && type != null) { // Type t = ReportTemplate.Type.valueOf(type.toUpperCase()); ReportTemplate ds = new ReportTemplateStandalone(null, FilenameUtils.getFullPath(file.getPath()), FilenameUtils.removeExtension(file.getName())); datasources.put(FilenameUtils.removeExtension(file.getName()), ds); //} } } } } else { throw new Exception("repo URL is null"); } } catch (Exception e) { System.out.println(e.getMessage()); } }
From source file:org.atomserver.core.filestore.FileBasedPhysicalStorageExplorer.java
/** * starts the exploration process. requires that you set a physicalStorage * * @throws org.atomserver.exceptions.AtomServerException *///w w w .j a va 2s . com public void explore() throws AtomServerException { if (this.physicalStorage == null) { throw new IllegalArgumentException( "Store is null. You must provide a store before calling the explore() method"); } File rootDir = this.physicalStorage.getRootDir(); log.debug(MessageFormat.format("Walking the store at {0}", rootDir.getPath())); StopWatch stopWatch = new AtomServerStopWatch(); try { beforeExploration(); List<String> childDirs = null; //allows the user to specify a child directory, otherwise it walks all top level directories if (this.childDirectories != null) { log.info(MessageFormat.format( "User specified child directories found ({0}) will not walk top level directories", this.childDirectories)); childDirs = childDirectories; } else { log.info("No user specified child directory. Exploring all top level directories."); childDirs = new ArrayList<String>(); Collection files = FileUtils.listFiles(rootDir, null, false); for (Iterator fileIter = files.iterator(); fileIter.hasNext();) { File subFile = (File) fileIter.next(); if (subFile.isDirectory() && !subFile.isHidden()) { log.info(MessageFormat.format("Discovered top level directory {0}", subFile.getName())); childDirs.add(subFile.getName()); } } } //iterate over each child dir and explore each one for (String childDir : childDirs) { log.info(MessageFormat.format("Exploring store {0}, child {1}", rootDir.getPath(), childDir)); boolean foundFiles = explore(rootDir, childDir); if (!foundFiles) { throw new AtomServerException("Did not find any files in " + rootDir + " " + childDir); } } afterExploration(); } finally { stopWatch.stop("Exploring the property store", ""); } // stopWatch.stop(); // log.warn("Exploring the property store took " + stopWatch.getElapsed() + " secs"); }
From source file:eu.esdihumboldt.hale.common.headless.impl.WorkspaceServiceImpl.java
/** * Triggers the service scanning for workspace folders where the lease time * has ended and deletes them.//ww w.java2 s . c om */ public void trigger() { for (File candidate : parentDir.listFiles(new FileFilter() { @Override public boolean accept(File file) { return !file.isHidden() && file.isDirectory() && configFile(file).exists(); } })) { // retrieve lease end time DateTime leaseEnd = null; try { PropertiesFile configFile = new PropertiesFile(configFile(candidate)); leaseEnd = DateTime.parse(configFile.getProperty(PROPERTY_LEASE_END)); } catch (Exception e) { log.error("Failed to retrieve workspace folder lease end time.", e); } if (leaseEnd != null) { if (leaseEnd.isBeforeNow()) { // delete folder try { FileUtils.deleteDirectory(candidate); } catch (IOException e) { log.error("Error deleting workspace folder", e); } if (candidate.exists()) { log.error("Failed to delete workspace folder, leaving it for next time."); } else { configFile(candidate).delete(); log.info("Removed workspace " + candidate.getName() + " after lease expired."); } } } } }
From source file:com.khubla.simpleioc.classlibrary.ClassLibrary.java
/** * scan a given directory// ww w . j a v a 2 s . c om */ private List<Class<?>> scan(File file, String concatenatedName) throws Exception { try { log.debug("scanning directory'" + file.getAbsolutePath() + "'"); /* * collection of all classes */ final List<Class<?>> ret = new ArrayList<Class<?>>(); if (file.isDirectory()) { final File[] files = file.listFiles(); if (null != files) { for (final File f : files) { if (false == f.isHidden()) { if (f.isDirectory()) { ret.addAll(scan(f, concatenatedName + f.getName() + ".")); } else { ret.addAll(scan(f, concatenatedName + f.getName())); } } } } } else { /* * its a file, could be a class file or a jar file, or neither */ if (file.getName().endsWith(CLASS)) { final ClassNode classNode = new ClassNode(); final ClassReader cr = new ClassReader(new FileInputStream(file.getAbsolutePath())); cr.accept(classNode, 0); if (annotated(classNode)) { ret.add(Class.forName(classNode.name.replaceAll("/", "."))); log.debug("adding " + classNode.name + " from " + file.getAbsolutePath()); } } else if (file.getName().endsWith(JAR)) { ret.addAll(crackJar(file.getAbsolutePath())); } } /* * done */ return ret; } catch (final Exception e) { throw new Exception("Exception in scan", e); } }