List of usage examples for java.io File isHidden
public boolean isHidden()
From source file:com.aliyun.odps.local.common.utils.LocalRunUtils.java
/** * ?????/*from w w w. j av a2 s .co m*/ */ public static List<File> listEmptyDirectory(File dir) { List<File> dataFiles = new ArrayList<File>(); File[] subDirs = dir.listFiles(new FileFilter() { @Override public boolean accept(File pathname) { return pathname.isDirectory() && !pathname.isHidden(); } }); for (File file : subDirs) { if (file.isDirectory()) { listEmptyDirectory(file, dataFiles); } } return dataFiles; }
From source file:nl.knaw.dans.common.lang.util.FileUtil.java
/** * Copy the file <code>original</code> to the file <code>destination</code>. * //from w ww . jav a2s . c o m * @param original * the original file * @param destination * the destination file * @throws IOException * for exceptions during IO */ public static void copyFile(File original, File destination) throws IOException { if (!original.exists()) { throw new FileNotFoundException("File not found: " + original.getName()); } if (original.isHidden()) { return; } if (original.equals(destination)) { throw new IOException("Cannot copy " + original.getName() + " into itself."); } if (original.isDirectory() && destination.isFile()) { throw new IOException("Cannot copy the contents of '" + original.getName() + "' to the file " + destination.getName()); } File finalDestination; if (destination.isDirectory()) { finalDestination = new File(destination, original.getName()); } else { finalDestination = destination; } if (original.isDirectory()) { finalDestination.mkdirs(); for (File f : original.listFiles()) { copyFile(f, finalDestination); } } else { FileInputStream fis = null; FileOutputStream fos = null; try { fis = new FileInputStream(original); fos = new FileOutputStream(finalDestination); byte[] buffer = new byte[4096]; int read = fis.read(buffer); while (read != -1) { fos.write(buffer, 0, read); read = fis.read(buffer); } } finally { closeStreams(fis, fos); } } }
From source file:com.l2jfree.gameserver.util.ModuleTester.java
private static void convertSkills() throws IOException { for (final File f : new File("../l2jfree-datapack/data/stats/skills/").listFiles()) { if (f.isHidden()) continue; new SkillXMLConverter(f).convert(); }/*w ww . j a v a2 s. c o m*/ }
From source file:net.tourbook.photo.ImageUtils.java
public static FileFilter createImageFileFilter() { return new FileFilter() { @Override// ww w.j ava 2 s .c om public boolean accept(final File pathname) { if (pathname.isDirectory()) { return false; } if (pathname.isHidden()) { return false; } final String name = pathname.getName(); if (name == null || name.length() == 0) { return false; } if (name.startsWith(".")) { //$NON-NLS-1$ return false; } if (Imaging.hasImageFileExtension(pathname)) { return true; } return false; } }; }
From source file:org.openmicroscopy.shoola.util.file.IOUtil.java
/** * Zips directory./*from ww w. j av a 2s.c o m*/ * * @param directory The directory to zip. * @param out The output stream. * @throws Exception Thrown if an error occurred during the operation. */ private static void zipDir(File directory, ZipOutputStream out, String parentDirectoryName) throws Exception { File[] entries = directory.listFiles(); byte[] buffer = new byte[4096]; // Create a buffer for copying int bytesRead; FileInputStream in; File f; for (int i = 0; i < entries.length; i++) { f = entries[i]; if (f.isHidden()) continue; if (f.isDirectory()) { zipDir(f, out, f.getName()); continue; } in = new FileInputStream(f); // Stream to read file String zipName = f.getName(); if (!StringUtils.isEmpty(parentDirectoryName)) { zipName = FilenameUtils.concat(parentDirectoryName, zipName); } out.putNextEntry(new ZipEntry(zipName)); // Store entry while ((bytesRead = in.read(buffer)) != -1) out.write(buffer, 0, bytesRead); out.closeEntry(); in.close(); } }
From source file:com.photon.phresco.service.docs.impl.DocumentUtil.java
private static void listFiles(File file, StringBuffer sb) { if (isDebugEnabled) { S_LOGGER.debug("Entering Method DocumentUtil.listFiles(File file,StringBuffer sb)"); }//from w w w. ja v a2 s.c o m String[] list = file.list(); sb.append("<ul>"); //$NON-NLS-1$ for (String fileOrFolder : list) { File newFile = new File(file.toString() + File.separator + fileOrFolder); if (newFile.isHidden()) continue; /*if(newFile.isDirectory()){ sb.append("<li>"); //$NON-NLS-1$ sb.append("<a href=./"); //$NON-NLS-1$ sb.append(newFile.getName()); sb.append("\">"); //$NON-NLS-1$ sb.append(newFile.getPath()); sb.append("</a>"); //$NON-NLS-1$ sb.append("</li>"); //$NON-NLS-1$ listFiles(newFile, sb); } else {*/ sb.append("<li>"); //$NON-NLS-1$ sb.append("<a href=" + "\"" + "./"); //$NON-NLS-1$ sb.append(newFile.getName()); sb.append("\">"); //$NON-NLS-1$ sb.append(newFile.getName()); sb.append("</a>"); //$NON-NLS-1$ sb.append("</li>"); //$NON-NLS-1$ // } } sb.append("</ul>"); //$NON-NLS-1$ }
From source file:edu.duke.igsp.gkde.Main.java
private static File[] getFiles(String directory, String[] files) { File[] inputFiles = null;// ww w .ja va 2 s .co m if (directory != null) { File dir = new File(directory); if (!dir.exists() || !dir.isDirectory()) { System.out.println("Directory parameter " + directory + " does not exist or is not a directory."); System.exit(1); } if (files.length == 0) { inputFiles = dir.listFiles(new FileFilter() { public boolean accept(File f) { return !f.isHidden() && f.isFile(); } }); } } else { directory = System.getProperty("user.dir"); } if (inputFiles == null) { inputFiles = new File[files.length]; for (int i = 0; i < files.length; ++i) { File f = new File(files[i]); boolean exists = false; if (!(exists = f.exists())) { f = new File(directory, files[i]); exists = f.exists(); } if (!exists) { System.out.println("Input file " + files[i] + " does not exist."); System.exit(1); } inputFiles[i] = f; } } return inputFiles; }
From source file:com.photon.phresco.framework.docs.impl.DocumentUtil.java
private static void listFiles(File file, StringBuffer sb) { if (isDebugEnabled) { S_LOGGER.debug("Entering Method DocumentUtil.listFiles(File file,StringBuffer sb)"); }//from ww w . jav a 2 s. c o m String[] list = file.list(); sb.append("<ul>"); //$NON-NLS-1$ for (String fileOrFolder : list) { File newFile = new File(file.toString() + File.separator + fileOrFolder); if (newFile.isHidden()) { continue; } /*if(newFile.isDirectory()){ sb.append("<li>"); //$NON-NLS-1$ sb.append("<a href=./"); //$NON-NLS-1$ sb.append(newFile.getName()); sb.append("\">"); //$NON-NLS-1$ sb.append(newFile.getPath()); sb.append("</a>"); //$NON-NLS-1$ sb.append("</li>"); //$NON-NLS-1$ listFiles(newFile, sb); } else {*/ sb.append("<li>"); //$NON-NLS-1$ sb.append("<a href=" + "\"" + "./"); //$NON-NLS-1$ sb.append(newFile.getName()); sb.append("\">"); //$NON-NLS-1$ sb.append(newFile.getName()); sb.append("</a>"); //$NON-NLS-1$ sb.append("</li>"); //$NON-NLS-1$ // } } sb.append("</ul>"); //$NON-NLS-1$ }
From source file:iaj.linkit.App.java
private static void handleFiles(final boolean recurse, final File... listFiles) { for (File f : listFiles) { if (f.getName().endsWith(EXTENSION_WEBLOC)) { handlePlist(f);//from w ww . ja v a 2 s .c o m } else if (f.getName().endsWith(EXTENSION_URL)) { handleIni(f); } else if (f.getName().endsWith(EXTENSION_URL.toLowerCase())) { handleIni(f); } else if (f.getName().endsWith(EXTENSION_DESKTOP)) { handleIni(f); } else if (recurse && f.isDirectory() && !f.isHidden()) { handleFiles(recurse, f.listFiles()); } } }
From source file:com.googlecode.osde.internal.igoogle.IgHostingUtil.java
private static void findAllRelativeFilePaths(String baseFolder, String relativeFolder, List<String> allPaths) { // Assert that relativeFolder ends with "/" unless it is empty. assert ((relativeFolder.length() == 0) || (relativeFolder.charAt(relativeFolder.length() - 1) == '/')); File currentFolder = new File(baseFolder, relativeFolder); for (File file : currentFolder.listFiles()) { String relativeFilePath = relativeFolder + file.getName(); if (file.isHidden()) { // Ignore any hidden file. } else if (file.isDirectory()) { findAllRelativeFilePaths(baseFolder, relativeFilePath + "/", allPaths); } else if (file.isFile()) { allPaths.add(relativeFilePath); } // Ignore all other kinds of files. }// ww w .j a v a2 s .c o m }