List of usage examples for java.io File isHidden
public boolean isHidden()
From source file:org.vb6.TestGenerator.java
public static void generateTestClass(final File vb6InputFile, final File outputDirectory, final String packageName) throws IOException { if (vb6InputFile.isFile() && !vb6InputFile.isHidden()) { final String inputFilename = firstToUpper(FilenameUtils.removeExtension(vb6InputFile.getName())); final File outputFile = new File(outputDirectory + "/" + inputFilename + "Test.java"); LOG.info("Creating {}.", outputFile); outputFile.createNewFile();// w w w.java 2s . co m final PrintWriter pWriter = new PrintWriter(new FileWriter(outputFile)); final String vb6InputFileName = vb6InputFile.getPath().replace("\\", "/"); pWriter.write("package " + packageName + ";\n"); pWriter.write("\n"); pWriter.write("import java.io.File;\n"); pWriter.write("\n"); pWriter.write("import org.junit.Test;\n"); pWriter.write("import org.vb6.runner.VbParseTestRunner;\n"); pWriter.write("import org.vb6.runner.impl.VbParseTestRunnerImpl;\n"); pWriter.write("\n"); pWriter.write("public class " + inputFilename + "Test {\n"); pWriter.write("\n"); pWriter.write(" @Test\n"); pWriter.write(" public void test() throws Exception {\n"); pWriter.write(" final File inputFile = new File(\"" + vb6InputFileName + "\");\n"); pWriter.write(" final VbParseTestRunner runner = new VbParseTestRunnerImpl();\n"); pWriter.write(" runner.parseFile(inputFile);\n"); pWriter.write(" }\n"); pWriter.write("}"); pWriter.flush(); pWriter.close(); } }
From source file:org.pentaho.metaverse.locator.LocatorTestUtils.java
private static RepositoryFileTree createFileTree(File root) { RepositoryFile repFile = new RepositoryFile(root.getPath(), root.getName(), root.isDirectory(), false, false, null, root.getAbsolutePath(), new Date(root.lastModified()), new Date(root.lastModified()), false, null, null, null, null, root.getName(), null, null, null, root.length(), "Admin", null); List<RepositoryFileTree> children = new ArrayList<RepositoryFileTree>(); File[] files = root.listFiles(); for (File file : files) { if (file.isHidden()) { continue; }/* w ww. j ava2 s. c om*/ if (file.isDirectory()) { RepositoryFileTree kid = createFileTree(file); children.add(kid); } else if (file.isFile()) { RepositoryFile kid = new RepositoryFile(file.getPath(), file.getName(), file.isDirectory(), false, false, null, file.getPath(), new Date(file.lastModified()), new Date(file.lastModified()), false, null, null, null, null, file.getName(), null, null, null, root.length(), "Admin", null); RepositoryFileTree kidTree = new RepositoryFileTree(kid, null); children.add(kidTree); } } RepositoryFileTree fileTree = new RepositoryFileTree(repFile, children); return fileTree; }
From source file:uk.ac.sanger.cgp.wwdocker.actions.Utils.java
public static List<File> getGnosKeys(BaseConfiguration config) { List<File> gnosKeys = new ArrayList(); Path dir = Paths.get(config.getString("gnosKeys")); try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir)) { for (Path item : stream) { File file = item.toFile(); if (file.isFile() && !file.isHidden()) { gnosKeys.add(file);//ww w . j a v a 2 s. co m } } } catch (IOException | DirectoryIteratorException e) { throw new RuntimeException(e.getMessage(), e); } return gnosKeys; }
From source file:org.opoo.press.util.StaleUtils.java
public static boolean isNewer(File dir, long compareTime, FileFilter filter) { File[] listFiles = dir.listFiles(filter); for (File file : listFiles) { if (file.isHidden()) { log.debug("Skip check hidden file: " + file); continue; }//from w w w. j ava 2s.c o m if (file.isFile()) { if (file.lastModified() > compareTime) { log.info("File {} changed.", file); return true; } } else if (file.isDirectory()) { if (isNewer(file, compareTime, filter)) { return true; } } } return false; }
From source file:uk.ac.sanger.cgp.wwdocker.actions.Utils.java
public static List<File> getWorkInis(BaseConfiguration config) { List<File> iniFiles = new ArrayList(); Path dir = Paths.get(config.getString("wfl_inis")); try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir)) { for (Path item : stream) { File file = item.toFile(); if (file.isFile() && file.canRead() && !file.isHidden()) { if (!file.getName().endsWith(".ini")) { continue; }/*from w w w . j a v a 2 s. c o m*/ iniFiles.add(file); } } } catch (IOException | DirectoryIteratorException e) { throw new RuntimeException(e.getMessage(), e); } return iniFiles; }
From source file:io.proleap.vb6.TestGenerator.java
public static void generateTestClasses(final File inputDirectory, final File outputDirectory, final String packageName) throws IOException { final String outputDirectoryPath = outputDirectory.getPath(); if (inputDirectory.isDirectory()) { // for each of the files in the directory for (final File inputDirectoryFile : inputDirectory.listFiles()) { // if the file is a VB6 relevant file if (inputDirectoryFile.isFile() && !inputDirectoryFile.isHidden() && (isClazzModule(inputDirectoryFile) || isStandardModule(inputDirectoryFile))) { generateTestClass(inputDirectoryFile, outputDirectory, packageName); generateTreeFile(inputDirectoryFile, inputDirectory); }// w w w . j a v a 2 s .c o m // else, if the file is a relevant directory else if (inputDirectoryFile.isDirectory() && !isDirectoryExcluded(inputDirectoryFile)) { final File subInputDirectory = inputDirectoryFile; final String subInputDirectoryName = subInputDirectory.getName(); if (!".".equals(subInputDirectoryName) && !"..".equals(subInputDirectoryName)) { /* * determine the output directory, where test classes * should be placed */ final File subOutputDirectory = new File(outputDirectoryPath + "/" + subInputDirectoryName); subOutputDirectory.mkdirs(); // determine the package name of test classes final String subPackageName = Strings.isBlank(packageName) ? subInputDirectoryName : packageName + "." + subInputDirectoryName; generateTestClasses(subInputDirectory, subOutputDirectory, subPackageName); } } } } }
From source file:org.cobol85.TestGenerator.java
public static void generateTestClass(final File cobol85InputFile, final File outputDirectory, final String packageName, final boolean isNonRepoTest) throws IOException { if (cobol85InputFile.isFile() && !cobol85InputFile.isHidden()) { final String inputFilename = firstToUpper(FilenameUtils.removeExtension(cobol85InputFile.getName())); final File outputFile = new File(outputDirectory + "/" + inputFilename + "Test.java"); LOG.info("Creating {}.", outputFile); final boolean createdNewFile = outputFile.createNewFile(); if (createdNewFile) { final PrintWriter pWriter = new PrintWriter(new FileWriter(outputFile)); final String defaultDirectoryName = "src/test/resources/org/cobol85/"; final String cobol85InputFileName = cobol85InputFile.getPath().replace("\\", "/"); pWriter.write("package " + packageName + ";\n"); pWriter.write("\n"); pWriter.write("import java.io.File;\n"); pWriter.write("\n"); pWriter.write("import org.junit.Test;\n"); pWriter.write("import org.cobol85.applicationcontext.Cobol85GrammarContextFactory;\n"); pWriter.write("import org.cobol85.runner.Cobol85ParseTestRunner;\n"); pWriter.write("import org.cobol85.runner.impl.Cobol85ParseTestRunnerImpl;\n"); pWriter.write("\n"); pWriter.write("public class " + inputFilename + "Test {\n"); pWriter.write("\n"); pWriter.write(" @Test\n"); pWriter.write(" public void test() throws Exception {\n"); pWriter.write(" Cobol85GrammarContextFactory.configureDefaultApplicationContext();\n"); pWriter.write("\n"); if (isNonRepoTest) { final String shortenedCobol85InputFileName = cobol85InputFileName.replace(defaultDirectoryName, ""); pWriter.write(//ww w . j a v a 2 s . c o m " final String testDirectoryString = System.getProperty(\"testDirectory\", \"" + defaultDirectoryName + "\");\n"); pWriter.write(" final File inputFile = new File(testDirectoryString, \"" + shortenedCobol85InputFileName + "\");\n"); } else { pWriter.write(" final File inputFile = new File(\"" + cobol85InputFileName + "\");\n"); } pWriter.write(" final Cobol85ParseTestRunner runner = new Cobol85ParseTestRunnerImpl();\n"); pWriter.write(" runner.parseFile(inputFile, null);\n"); pWriter.write(" }\n"); pWriter.write("}"); pWriter.flush(); pWriter.close(); } } }
From source file:com.thoughtworks.go.util.FileUtil.java
public static boolean isHidden(File file) { return file.isHidden() || file.getName().startsWith("."); }
From source file:io.proleap.cobol.TestGenerator.java
public static void generateTestClasses(final File inputDirectory, final File outputDirectory, final String packageName) throws IOException { final String outputDirectoryPath = outputDirectory.getPath(); if (inputDirectory.isDirectory()) { // for each of the files in the directory for (final File inputDirectoryFile : inputDirectory.listFiles()) { // if the file is a Cobol relevant file if (inputDirectoryFile.isFile() && !inputDirectoryFile.isHidden() && isCobolFile(inputDirectoryFile)) { generateTestClass(inputDirectoryFile, outputDirectory, packageName); generateTreeFile(inputDirectoryFile, inputDirectory); }/* w ww . j ava 2 s .co m*/ // else, if the file is a relevant directory else if (inputDirectoryFile.isDirectory() && !isDirectoryExcluded(inputDirectoryFile)) { final File subInputDirectory = inputDirectoryFile; final String subInputDirectoryName = subInputDirectory.getName(); if (!".".equals(subInputDirectoryName) && !"..".equals(subInputDirectoryName)) { /* * determine the output directory, where test classes * should be placed */ final File subOutputDirectory = new File(outputDirectoryPath + "/" + subInputDirectoryName); subOutputDirectory.mkdirs(); // determine the package name of test classes final String subPackageName = Strings.isBlank(packageName) ? subInputDirectoryName : packageName + "." + subInputDirectoryName; generateTestClasses(subInputDirectory, subOutputDirectory, subPackageName); } } } } }
From source file:de.petermoesenthin.alarming.util.FileUtil.java
/** * Returns a file list of all non-hidden files in the application directory. * * @return// w w w. j a va 2 s. co m */ public static File[] getAlarmDirectoryFileList() { return FileUtil.getApplicationDirectory().listFiles(new FileFilter() { @Override public boolean accept(File f) { return !f.isHidden(); } }); }