List of usage examples for java.io File isHidden
public boolean isHidden()
From source file:org.sonar.server.startup.GwtPublisher.java
protected void cleanDirectory() { try {/* w w w. j a v a 2s .c om*/ if (outputDir != null && outputDir.exists()) { File[] files = outputDir.listFiles(); if (files != null) { for (File file : files) { // avoid issues with SCM hidden dirs if (!file.isHidden()) { if (file.isDirectory()) { FileUtils.deleteDirectory(file); FileUtils.deleteDirectory(file); } else { file.delete(); } } } } } } catch (IOException e) { LOG.warn("can not clean the directory " + outputDir, e); } }
From source file:nz.ac.otago.psyanlab.common.ImportPaleActivity.java
@Override public FilenameFilter getfilter() { return new FilenameFilter() { private Pattern mFileNamePattern = Pattern.compile(".*\\.pale", Pattern.CASE_INSENSITIVE); @Override//from ww w . j a v a2 s . com public boolean accept(File dir, String filename) { File f = new File(dir, filename); if (f.isHidden()) { return false; } if (f.isDirectory()) { return true; } return mFileNamePattern.matcher(filename).matches(); } }; }
From source file:com.appeligo.showfiles.FilesByTime.java
private void addFile(Set<File> fileSet, File file) { if (file.isHidden()) { return;// w ww.ja v a 2 s .c om } if (file.isDirectory()) { for (File child : file.listFiles()) { addFile(fileSet, child); } } else { fileSet.add(file); } }
From source file:gov.gtas.job.scheduler.LoaderScheduler.java
private void processInputAndOutputDirectories(Path incomingDir, Path outgoingDir, LoaderStatistics stats) { // No hidden files. DirectoryStream.Filter<Path> filter = entry -> { File f = entry.toFile(); return !f.isHidden() && f.isFile(); };/*from w w w . j a va 2s. c o m*/ try (DirectoryStream<Path> stream = Files.newDirectoryStream(incomingDir, filter)) { final Iterator<Path> iterator = stream.iterator(); List<File> files = new ArrayList<>(); for (int i = 0; iterator.hasNext() && i < maxNumofFiles; i++) { files.add(iterator.next().toFile()); } Collections.sort(files, LastModifiedFileComparator.LASTMODIFIED_COMPARATOR); files.stream().forEach(f -> { processSingleFile(f, stats); f.renameTo(new File(outgoingDir.toFile() + File.separator + f.getName())); }); stream.close(); } catch (IOException ex) { logger.error("IOException:" + ex.getMessage(), ex); ErrorDetailInfo errInfo = ErrorHandlerFactory.createErrorDetails(ex); errorPersistenceService.create(errInfo); } }
From source file:org.saiku.adhoc.server.datasource.ClassPathResourcePRPTManager.java
public void load() { datasources.clear();//ww w . ja v a2s.co 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 ReportTemplateServer(null, file.getCanonicalPath(), file.getName()); datasources.put(file.getName(), ds); //} } } } } else { throw new Exception("repo URL is null"); } } catch (Exception e) { System.out.println(e.getMessage()); } }
From source file:org.apache.taverna.component.registry.local.LocalComponentRegistry.java
@Override protected void populateProfileCache() throws ComponentException { File profilesDir = getComponentProfilesDir(); for (File subFile : profilesDir.listFiles()) if (subFile.isFile() && (!subFile.isHidden()) && subFile.getName().endsWith(".xml")) try { profileCache.add(new LocalComponentProfile(subFile)); } catch (MalformedURLException e) { logger.error("Unable to read profile", e); }//from ww w . jav a 2 s .c o m }
From source file:forge.deck.io.DeckGroupSerializer.java
@Override protected FilenameFilter getFileFilter() { return new FilenameFilter() { @Override/*from w w w.jav a 2s . c o m*/ public boolean accept(final File dir, final String name) { final File testSubject = new File(dir, name); final boolean isVisibleFolder = testSubject.isDirectory() && !testSubject.isHidden(); final boolean hasGoodName = StringUtils.isNotEmpty(name) && !name.startsWith("."); final File fileHumanDeck = new File(testSubject, DeckGroupSerializer.humanDeckFile); return isVisibleFolder && hasGoodName && fileHumanDeck.exists(); } }; }
From source file:org.apache.tajo.HttpFileServerHandler.java
@Override public void channelRead0(ChannelHandlerContext ctx, FullHttpRequest request) throws Exception { if (request.getMethod() != HttpMethod.GET) { sendError(ctx, HttpResponseStatus.METHOD_NOT_ALLOWED); return;// ww w . ja va 2 s.c o m } final String path = sanitizeUri(request.getUri()); if (path == null) { sendError(ctx, HttpResponseStatus.FORBIDDEN); return; } File file = new File(path); if (file.isHidden() || !file.exists()) { sendError(ctx, HttpResponseStatus.NOT_FOUND); return; } if (!file.isFile()) { sendError(ctx, HttpResponseStatus.FORBIDDEN); return; } RandomAccessFile raf; try { raf = new RandomAccessFile(file, "r"); } catch (FileNotFoundException fnfe) { sendError(ctx, HttpResponseStatus.NOT_FOUND); return; } long fileLength = raf.length(); HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK); HttpHeaders.setContentLength(response, fileLength); setContentTypeHeader(response); // Write the initial line and the header. ctx.write(response); // Write the content. ChannelFuture writeFuture; ChannelFuture lastContentFuture; if (ctx.pipeline().get(SslHandler.class) != null) { // Cannot use zero-copy with HTTPS. lastContentFuture = ctx.writeAndFlush(new HttpChunkedInput(new ChunkedFile(raf, 0, fileLength, 8192)), ctx.newProgressivePromise()); } else { // No encryption - use zero-copy. final FileRegion region = new DefaultFileRegion(raf.getChannel(), 0, fileLength); writeFuture = ctx.write(region, ctx.newProgressivePromise()); lastContentFuture = ctx.writeAndFlush(LastHttpContent.EMPTY_LAST_CONTENT); writeFuture.addListener(new ChannelProgressiveFutureListener() { @Override public void operationProgressed(ChannelProgressiveFuture future, long progress, long total) throws Exception { LOG.trace(String.format("%s: %d / %d", path, progress, total)); } @Override public void operationComplete(ChannelProgressiveFuture future) throws Exception { LOG.trace(future.channel() + " Transfer complete."); } }); } // Decide whether to close the connection or not. if (!HttpHeaders.isKeepAlive(request)) { // Close the connection when the whole content is written out. lastContentFuture.addListener(ChannelFutureListener.CLOSE); } }
From source file:com.app.sample.chatting.activity.chat.FacePageFragment.java
@Override protected void initData() { super.initData(); String folderPath = getArguments().getString(FACE_FOLDER_PATH); if (StringUtils.isEmpty(folderPath)) { folderPath = ""; Log.e("kymjs", getClass().getSimpleName() + " line 69, folder path is empty"); }/*from w w w.j a v a 2 s . co m*/ File folder = new File(folderPath); if (folder.isDirectory()) { File[] faceFiles = folder.listFiles(); datas = new ArrayList<>(faceFiles.length); for (File faceFile : faceFiles) { if (!faceFile.isHidden()) { Faceicon data = new Faceicon(); data.setName("http://www.oschina.net/image/" + faceFile.getName()); data.setFileName(faceFile.getName()); data.setPath(faceFile.getAbsolutePath()); datas.add(data); } } } else { datas = new ArrayList<>(0); } }
From source file:com.tc.l2.logging.TCLoggingTest.java
public void testRollover() throws Exception { String logDir = "/tmp/terracotta/test/com/tc/logging"; File logDirFolder = new File(logDir); logDirFolder.mkdirs();/*from ww w.j a va 2s. co m*/ try { FileUtils.cleanDirectory(logDirFolder); } catch (IOException e) { Assert.fail("Unable to clean the temp log directory !! Exiting..."); } final int LOG_ITERATIONS = 5; for (int i = 0; i < LOG_ITERATIONS; i++) { createLogs(logDir); } File[] listFiles = logDirFolder.listFiles(); int logFileCount = 0; for (File file : listFiles) { String ext = file.getName().substring(file.getName().lastIndexOf('.') + 1); if (!file.isHidden() && ext.equals("log")) { logFileCount++; } } // Always one extra file is created by log4j Assert.assertEquals(LOG_ITERATIONS + 1, logFileCount); }