List of usage examples for java.io File isHidden
public boolean isHidden()
From source file:com.twosigma.beaker.core.rest.FileIORest.java
private static List<Map<String, Object>> getChildren(String path, List<String> openFolders) { File f = new File(path); File[] children = f.listFiles(); List<Map<String, Object>> ret = new ArrayList<>(children.length); for (File cf : children) { if (!cf.isHidden()) { String childPath = cf.getPath(); Map<String, Object> map = new HashMap<>(); map.put("uri", childPath); map.put("modified", cf.lastModified()); map.put("type", cf.isDirectory() ? "directory" : getMimeTypeForFileName(cf.getPath())); String prettyChildPath = childPath + "/"; if (openFolders.contains(prettyChildPath)) { map.put("children", getChildren(childPath, openFolders)); }/*from ww w . ja va2 s. co m*/ ret.add(map); } } return ret; }
From source file:org.onexus.resource.manager.internal.providers.AbstractProjectProvider.java
private static Collection<File> addFilesRecursive(Collection<File> files, File parentFolder) { if (parentFolder.isDirectory()) { File[] inFiles = parentFolder.listFiles(); if (inFiles != null) { for (File file : inFiles) { if (!file.isHidden()) { files.add(file);/* w ww. ja va2 s. c o m*/ if (file.isDirectory()) { addFilesRecursive(files, file); } } } } } return files; }
From source file:org.broad.igv.util.FileUtils.java
/** * Replace all occurences of str1 with str2 in all files in inputDirectory. Write the modified files * to outputDirectory. Note: assumption is all files are text. * * @param inputDirectory/*from w w w.j av a 2 s . c om*/ * @param outputDirectory * @param str1 * @param str2 */ public static void searchAndReplace(File inputDirectory, File outputDirectory, String str1, String str2) throws IOException { for (File in : inputDirectory.listFiles()) { if (!in.isDirectory() && !in.isHidden()) { File of = new File(outputDirectory, in.getName()); BufferedReader reader = null; PrintWriter pw = null; try { reader = new BufferedReader(new FileReader(in)); pw = new PrintWriter(new BufferedWriter(new FileWriter(of))); String nextLine; while ((nextLine = reader.readLine()) != null) { nextLine = nextLine.replaceAll(str1, str2); pw.println(nextLine); } } finally { reader.close(); pw.close(); } } } }
From source file:com.qmetry.qaf.automation.util.FileUtil.java
public static Collection<File> listFiles(File directory, FilenameFilter filter, boolean recurse) { // List of files / directories Vector<File> files = new Vector<File>(); // Get files / directories in the directory File[] entries = directory.listFiles(); // Go over entries for (File entry : entries) { if ((filter == null) || filter.accept(directory, entry.getName())) { files.add(entry);/*from www .ja va 2s . c o m*/ } // If the file is a directory and the recurse flag // is set, recurse into the directory if (recurse && entry.isDirectory() && !entry.isHidden()) { files.addAll(listFiles(entry, filter, recurse)); } } // Return collection of files return files; }
From source file:com.themodernway.server.core.io.IO.java
public static final boolean isHidden(final File file) { return file.isHidden(); }
From source file:org.apache.jena.fuseki.build.FusekiConfig.java
/** Read service descriptions in the given directory */ public static List<DataAccessPoint> readConfigurationDirectory(String dir) { Path pDir = Paths.get(dir).normalize(); File dirFile = pDir.toFile(); if (!dirFile.exists()) { log.warn("Not found: directory for assembler files for services: '" + dir + "'"); return Collections.emptyList(); }/*w w w . j av a 2s . c om*/ if (!dirFile.isDirectory()) { log.warn("Not a directory: '" + dir + "'"); return Collections.emptyList(); } // Files that are not hidden. DirectoryStream.Filter<Path> filter = (entry) -> { File f = entry.toFile(); final Lang lang = filenameToLang(f.getName()); return !f.isHidden() && f.isFile() && lang != null && isRegistered(lang); }; List<DataAccessPoint> dataServiceRef = new ArrayList<>(); try (DirectoryStream<Path> stream = Files.newDirectoryStream(pDir, filter)) { for (Path p : stream) { DatasetDescriptionMap dsDescMap = new DatasetDescriptionMap(); String fn = IRILib.filenameToIRI(p.toString()); log.info("Load configuration: " + fn); Model m = readAssemblerFile(fn); readConfiguration(m, dsDescMap, dataServiceRef); } } catch (IOException ex) { log.warn("IOException:" + ex.getMessage(), ex); } return dataServiceRef; }
From source file:org.geotools.gce.imagecollection.Utils.java
/** * Checks that a {@link File} is a real file, exists and is readable. * /*from w w w . ja v a 2 s.co m*/ * @param file * the {@link File} instance to check. Must not be null. * * @return <code>true</code> in case the file is a real file, exists and is * readable; <code>false </code> otherwise. */ static boolean checkFileReadable(final File file) { if (LOGGER.isLoggable(Level.FINE)) { final StringBuilder builder = new StringBuilder(); builder.append("Checking file:").append(FilenameUtils.getFullPath(file.getAbsolutePath())).append("\n"); builder.append("canRead:").append(file.canRead()).append("\n"); builder.append("isHidden:").append(file.isHidden()).append("\n"); builder.append("isFile").append(file.isFile()).append("\n"); builder.append("canWrite").append(file.canWrite()).append("\n"); LOGGER.fine(builder.toString()); } if (!file.exists() || !file.canRead() || !file.isFile()) return false; return true; }
From source file:com.newatlanta.appengine.junit.vfs.gae.GaeVfsTestCase.java
public static void assertEquals(File file, FileObject fileObject) throws Exception { assertEqualPaths(file, fileObject);//from ww w . j a va2s.c o m assertEquals(file.canRead(), fileObject.isReadable()); assertEquals(file.canWrite(), fileObject.isWriteable()); assertEquals(file.exists(), fileObject.exists()); if (file.getParentFile() == null) { assertNull(fileObject.getParent()); } else { assertEqualPaths(file.getParentFile(), fileObject.getParent()); } assertEquals(file.isDirectory(), fileObject.getType().hasChildren()); assertEquals(file.isFile(), fileObject.getType().hasContent()); assertEquals(file.isHidden(), fileObject.isHidden()); if (file.isFile()) { assertEquals(file.length(), fileObject.getContent().getSize()); } if (file.isDirectory()) { // same children File[] childFiles = file.listFiles(); FileObject[] childObjects = fileObject.getChildren(); assertEquals(childFiles.length, childObjects.length); for (int i = 0; i < childFiles.length; i++) { assertEqualPaths(childFiles[i], childObjects[i]); } } }
From source file:com.amaze.filemanager.filesystem.RootHelper.java
public static HybridFileParcelable generateBaseFile(File x, boolean showHidden) { long size = 0; if (!x.isDirectory()) size = x.length();/*from w w w .j av a 2 s.co m*/ HybridFileParcelable baseFile = new HybridFileParcelable(x.getPath(), parseFilePermission(x), x.lastModified(), size, x.isDirectory()); baseFile.setName(x.getName()); baseFile.setMode(OpenMode.FILE); if (showHidden) { return (baseFile); } else if (!x.isHidden()) { return (baseFile); } return null; }
From source file:com.amaze.carbonfilemanager.filesystem.RootHelper.java
public static BaseFile generateBaseFile(File x, boolean showHidden) { long size = 0; if (!x.isDirectory()) size = x.length();// w w w. j a v a2 s. c om BaseFile baseFile = new BaseFile(x.getPath(), parseFilePermission(x), x.lastModified(), size, x.isDirectory()); baseFile.setName(x.getName()); baseFile.setMode(OpenMode.FILE); if (showHidden) { return (baseFile); } else if (!x.isHidden()) { return (baseFile); } return null; }