List of usage examples for java.io File isHidden
public boolean isHidden()
From source file:org.apache.ode.store.DeploymentUnitDir.java
private List<File> allFiles(File dir) { ArrayList<File> result = new ArrayList<File>(); for (File file : dir.listFiles()) { if (file.isDirectory()) { result.addAll(allFiles(file)); }/*from w ww . j a v a 2 s. c o m*/ if (file.isHidden()) continue; if (file.isFile()) { result.add(file); } } return result; }
From source file:org.isatools.isacreator.formatmappingutility.logic.MappingLogic.java
/** * Will read in the file parsed by the loader add add each row as it comes! * * @param headers - Column names as an Array of Strings * @param substitutions - List of substitutions as <<1>>-<<4>><<8>> and so on * @param tro - @see TableReferenceObject *//* w w w . j ava2 s. c o m*/ private void createDataForTRO(String[] headers, List<String> substitutions, TableReferenceObject tro) { try { String[] subsAsArray = substitutions.toArray(new String[substitutions.size()]); int rowOffSet; try { rowOffSet = Integer.parseInt(ISAcreatorProperties.getProperty("isacreator.rowOffset")) - 1; } catch (NumberFormatException nfe) { rowOffSet = 0; } if (readerToUse == FileLoader.CSV_READER_CSV || readerToUse == FileLoader.CSV_READER_TXT) { char delimiter = (readerToUse == FileLoader.CSV_READER_CSV) ? FileLoader.COMMA_DELIM : FileLoader.TAB_DELIM; CSVReader fileReader = new CSVReader(new FileReader(fileName), delimiter); // read first line to discard it! String[] nextLine; int count = 0; while ((nextLine = fileReader.readNext()) != null) { // we don't want the column names as well! if (count != 0 && count > rowOffSet) { // we decrement count since we're skipping 0. addDataToTRO(headers, subsAsArray, nextLine, tro); } count++; } } else if (readerToUse == FileLoader.SHEET_READER) { // read the file using the Sheet reader from jxl library Workbook w; try { File f = new File(fileName); if (!f.isHidden()) { w = Workbook.getWorkbook(f); // Get the first sheet for (Sheet s : w.getSheets()) { if (s.getRows() > 1) { for (int row = rowOffSet + 1; row < s.getRows(); row++) { String[] nextLine = new String[s.getColumns()]; for (int col = 0; col < s.getColumns(); col++) { nextLine[col] = s.getCell(col, row).getContents(); } addDataToTRO(headers, subsAsArray, nextLine, tro); } } break; } } } catch (BiffException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } else { log.info(" no reader available for use! "); } } catch (IOException e) { log.error(e.getMessage()); } }
From source file:org.apache.webdav.ui.WebdavSystemView.java
/** * Returns whether a file is hidden or not. */ public boolean isHiddenFile(File f) { return f.isHidden(); }
From source file:eu.esdihumboldt.util.scavenger.AbstractResourceScavenger.java
/** * @see ResourceScavenger#triggerScan()/*from w w w . j av a2 s . co m*/ */ @Override public void triggerScan() { synchronized (resources) { if (huntingGrounds != null) { if (huntingGrounds.isDirectory()) { // scan for sub-directories Set<String> foundIds = new HashSet<String>(); File[] resourceDirs = huntingGrounds.listFiles(new FileFilter() { @Override public boolean accept(File pathname) { // accept non-hidden directories return pathname.isDirectory() && !pathname.isHidden(); } }); for (File resourceDir : resourceDirs) { String resourceId = resourceDir.getName(); foundIds.add(resourceId); if (!resources.containsKey(resourceId)) { // resource reference not loaded yet T reference; try { reference = loadReference(resourceDir, null, resourceId); resources.put(resourceId, reference); onAdd(reference, resourceId); } catch (IOException e) { log.error("Error creating resource reference", e); } } else { // update existing resource updateResource(resources.get(resourceId), resourceId); } } Set<String> removed = new HashSet<String>(resources.keySet()); removed.removeAll(foundIds); // deal with resources that have been removed for (String resourceId : removed) { T reference = resources.remove(resourceId); if (reference != null) { // remove active environment onRemove(reference, resourceId); } } } else { // one project mode if (!resources.containsKey(DEFAULT_RESOURCE_ID)) { // project configuration not loaded yet T reference; try { reference = loadReference(huntingGrounds.getParentFile(), huntingGrounds.getName(), DEFAULT_RESOURCE_ID); resources.put(DEFAULT_RESOURCE_ID, reference); onAdd(reference, DEFAULT_RESOURCE_ID); } catch (IOException e) { log.error("Error creating project handler", e); } } else { // update existing project updateResource(resources.get(DEFAULT_RESOURCE_ID), DEFAULT_RESOURCE_ID); } } } } }
From source file:net.pms.dlna.MapFile.java
@Override public void discoverChildren(String str) { if (discoverable == null) { discoverable = new ArrayList<>(); } else {/*w w w .j ava 2s.c o m*/ return; } int sm = configuration.getSortMethod(getPath()); List<File> files = getFileList(); // ATZ handling if (files.size() > configuration.getATZLimit() && StringUtils.isEmpty(forcedName)) { /* * Too many files to display at once, add A-Z folders * instead and let the filters begin * * Note: If we done this at the level directly above we don't do it again * since all files start with the same letter then */ TreeMap<String, ArrayList<File>> map = new TreeMap<>(); for (File f : files) { if ((!f.isFile() && !f.isDirectory()) || f.isHidden()) { // skip these continue; } if (f.isDirectory() && configuration.isHideEmptyFolders() && !FileUtil.isFolderRelevant(f, configuration)) { LOGGER.debug("Ignoring empty/non-relevant directory: " + f.getName()); // Keep track of the fact that we have empty folders, so when we're asked if we should refresh, // we can re-scan the folders in this list to see if they contain something relevant if (emptyFoldersToRescan == null) { emptyFoldersToRescan = new ArrayList<>(); } if (!emptyFoldersToRescan.contains(f)) { emptyFoldersToRescan.add(f); } continue; } String filenameToSort = FileUtil.renameForSorting(f.getName()); char c = filenameToSort.toUpperCase().charAt(0); if (!(c >= 'A' && c <= 'Z')) { // "other char" c = '#'; } ArrayList<File> l = map.get(String.valueOf(c)); if (l == null) { // new letter l = new ArrayList<>(); } l.add(f); map.put(String.valueOf(c), l); } for (String letter : map.keySet()) { // loop over all letters, this avoids adding // empty letters ArrayList<File> l = map.get(letter); UMSUtils.sort(l, sm); MapFile mf = new MapFile(getConf(), l); mf.forcedName = letter; addChild(mf); } return; } UMSUtils.sort(files, (sm == UMSUtils.SORT_RANDOM ? UMSUtils.SORT_LOC_NAT : sm)); for (File f : files) { if (f.isDirectory()) { discoverable.add(f); // manageFile(f); } } // For random sorting, we only randomize file entries if (sm == UMSUtils.SORT_RANDOM) { UMSUtils.sort(files, sm); } for (File f : files) { if (f.isFile()) { discoverable.add(f); // manageFile(f); } } }
From source file:de.u808.simpleinquest.indexer.impl.IndexUpdater.java
public void processFile(File file) { //Listen vergleichen //File in die entsprechenden Listen sortieren if (file != null && file.canRead() && !file.isHidden()) { TermQuery query = new TermQuery(new Term(Indexer.PATH_FIELD_NAME, file.getPath())); Hits hits = null;/*www . j a v a 2s.c o m*/ try { if (!newIndex) { hits = this.indexSearcher.search(query); } if (hits != null && hits.length() > 0) { Document doc = hits.doc(0); String directoryList = doc.getField(Indexer.DIRECTORY_LIST_FIELD_NAME).stringValue(); this.processDirectoryList(file, directoryList); } else { //New dir, add all this.addToNewFilesList(file); File[] files = file.listFiles(); if (files != null) { for (File f : files) { if (f.isFile()) { this.addToNewFilesList(f); } } } } } catch (IOException e) { log.error(e); } } else { log.info("Ignoring file: " + file.getPath()); } }
From source file:com.kii.demo.sync.ui.fragments.FileListFragment.java
public void refreshFilesList() { // Clear the files ArrayList mFiles.clear();//from ww w . j a va 2 s.c om // Set the extension file filter ExtensionFilenameFilter filter = new ExtensionFilenameFilter(acceptedFileExtensions); // Get the files in the directory File[] files = mDirectory.listFiles(filter); if ((files != null) && (files.length > 0)) { for (File f : files) { if (f.isHidden() && !mShowHiddenFiles) { // Don't add the file continue; } // Add the file the ArrayAdapter mFiles.add(f); } Collections.sort(mFiles, new FileComparator()); } mAdapter.notifyDataSetChanged(); Button b = (Button) mView.findViewById(R.id.button_right); if (isAtSdHome()) { // at SD card home, disable Up button b.setEnabled(false); } else { b.setEnabled(true); } TextView tv = (TextView) mView.findViewById(R.id.header_text); tv.setText(getString(R.string.header_text_path) + mDirectory.getPath()); }
From source file:com.otway.picasasync.syncutil.AlbumSync.java
private List<ImageSync> buildImageList(PicasawebClient webClient, File localFolder, AlbumEntry albumEntry, final LocalDateTime oldestDate) throws IOException, ServiceException { List<ImageSync> allImages = new ArrayList<ImageSync>(); syncManager.getSyncState().setStatus("Querying Google for album " + albumEntry.getTitle().getPlainText()); // Get the list of remote photos List<PhotoEntry> photos = webClient.getPhotos(albumEntry); // Deal with the fact that an album can have multiple images with the same local filename. HashMap<String, List<PhotoEntry>> fileGroups = new HashMap<String, List<PhotoEntry>>(); for (PhotoEntry photo : photos) { String imageName = photo.getTitle().getPlainText().toLowerCase(); if (FilenameUtils.getExtension(imageName).toLowerCase().equals(".mov")) { log.info("Skipping file " + imageName + " with .mov file extension."); continue; }/*from w w w. j a v a 2 s . c om*/ List<PhotoEntry> photoList = null; if (!fileGroups.containsKey(imageName)) { photoList = new ArrayList<PhotoEntry>(); fileGroups.put(imageName, photoList); } else photoList = fileGroups.get(imageName); photoList.add(photo); } // So now we have a map of image name => List of photo entries which use that name. List<PhotoEntry> nonDupePhotos = new ArrayList<PhotoEntry>(); int dupesDiscarded = 0; for (List<PhotoEntry> list : fileGroups.values()) { String maxId = null; PhotoEntry photoToUse = null; for (PhotoEntry photo : list) { String id = PicasawebClient.getPhotoId(photo); // We'll arbitrarily pick the one with the lowest ID, and ignore the rest. if (maxId == null || maxId.compareTo(id) == -1) { maxId = id; photoToUse = photo; } } nonDupePhotos.add(photoToUse); dupesDiscarded += list.size() - 1; } if (dupesDiscarded > 0) { log.info("Ignoring " + dupesDiscarded + " duplicate photos of " + photos.size() + " from album " + getAlbumName()); } List<ImageSync> remoteImages = new ArrayList<ImageSync>(); for (PhotoEntry photo : nonDupePhotos) { String imageFile = photo.getTitle().getPlainText(); if (settings.getExcludeVideos() && photo.getMediaContents().size() > 1) { log.info("Exclude Video enabled: skipping " + imageFile); continue; } File localFileName = new File(localFolder, imageFile); remoteImages.add(new ImageSync(photo, localFileName)); } log.debug(remoteImages.size() + " remote images found in " + albumEntry.getTitle().getPlainText()); // Get the local file list File[] files = localFolder.listFiles(new FilenameFilter() { public boolean accept(File current, String name) { File file = new File(current, name); return file.isFile() && !file.isHidden(); } }); List<ImageSync> localFiles = new ArrayList<ImageSync>(); if (files != null && files.length > 0) { log.info(files.length + " local files found in " + localFolder); // Now, pull out all the local files that aren't in the list. // These are the new files that we'll upload for (File localFile : files) { if (!fileGroups.containsKey(localFile.getName().toLowerCase())) { localFiles.add(new ImageSync(null, localFile)); } } } log.debug(localFiles.size() + " local images found in " + localFolder); allImages.addAll(localFiles); // Add the remote images after. Uploads are higher priority than downloads allImages.addAll(remoteImages); log.debug(allImages.size() + " images found (new local + remote)"); // And finally, filter out anything that's too old. List<ImageSync> result = new ArrayList<ImageSync>(); for (ImageSync image : allImages) if (image.newerThan(oldestDate)) result.add(image); log.debug(result.size() + " total images after date filter applied."); return result; }