List of usage examples for java.io File isHidden
public boolean isHidden()
From source file:org.openmicroscopy.shoola.agents.fsimporter.chooser.ImportDialog.java
/** * Returns <code>true</code> if the file can be imported, <code>false</code> * otherwise.//from w ww. ja v a 2 s. c om * * @param f * The file to check. * @return See above. */ private boolean isFileImportable(File f) { return !(f == null || f.isHidden()); }
From source file:com.qspin.qtaste.ui.TestCaseTree.java
protected void addChildToTree(File file, DefaultMutableTreeNode parent) { if (!file.isDirectory()) { return;/*from ww w .ja v a 2 s . c o m*/ } FileNode fn = new FileNode(file, file.getName(), getTestCasePane().getTestSuiteDirectory()); // check if the directory is the child one containing data files boolean nodeToAdd = fn.isTestcaseDir(); if (!fn.isTestcaseDir()) { // go recursilvely to its child and check if it must be added nodeToAdd = checkIfDirectoryContainsTestScriptFile(file); } if (!nodeToAdd) { return; } TCTreeNode node = new TCTreeNode(fn, !fn.isTestcaseDir()); final int NON_EXISTENT = -1; if (parent.getIndex(node) == NON_EXISTENT && !file.isHidden()) { parent.add(node); } }
From source file:org.openmicroscopy.shoola.agents.fsimporter.chooser.ImportDialog.java
/** * Checks if the file can be added to the passed list. Returns the * <code>true</code> if the file is a directory, <code>false</code> * otherwise.// w ww .j a v a 2s . c o m * * @param f * The file to handle. */ private boolean checkFile(File f, List<FileObject> l) { if (f == null || f.isHidden()) return false; if (f.isFile()) { if (isFileImportable(f)) l.add(new FileObject(f)); } else if (f.isDirectory()) { File[] list = f.listFiles(); if (list != null && list.length > 0) { l.add(new FileObject(f)); return true; } } return false; }
From source file:com.sentaroh.android.Utilities.Dialog.FileSelectDialogFragment.java
private TreeFilelistItem buildTreeFileListItem(File fl, String fp) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.getDefault()); String tfs = MiscUtil.convertFileSize(fl.length()); TreeFilelistItem tfi = null;//w w w. j a v a 2s . c om if (fl.isDirectory()) { tfi = new TreeFilelistItem(fl.getName(), sdf.format(fl.lastModified()) + ", ", true, 0, 0, false, fl.canRead(), fl.canWrite(), fl.isHidden(), fp, 0); } else { tfi = new TreeFilelistItem(fl.getName(), sdf.format(fl.lastModified()) + "," + tfs, false, fl.length(), fl.lastModified(), false, fl.canRead(), fl.canWrite(), fl.isHidden(), fp, 0); } return tfi; }
From source file:org.openmicroscopy.shoola.agents.fsimporter.chooser.ImportDialog.java
/** * Handles the selection of files. Returns the files that can be imported. * /* ww w. j av a2 s . c o m*/ * @param The selected files. * @return See above. */ private int handleFilesSelection(File[] files) { int count = 0; if (files == null) return count; File f; for (int i = 0; i < files.length; i++) { f = files[i]; if (!f.isHidden()) { count++; } } return count; }
From source file:org.dcm4che2.tool.dcmsnd.DcmSnd.java
public void addFile(File f) { if (f.isDirectory()) { File[] fs = f.listFiles(); if (fs == null || fs.length == 0) return; for (int i = 0; i < fs.length; i++) addFile(fs[i]);/* w ww .j a v a2 s . c o m*/ return; } if (f.isHidden()) return; FileInfo info = new FileInfo(f); DicomObject dcmObj = new BasicDicomObject(); DicomInputStream in = null; try { in = new DicomInputStream(f); in.setHandler(new StopTagInputHandler(Tag.StudyDate)); in.readDicomObject(dcmObj, PEEK_LEN); info.tsuid = in.getTransferSyntax().uid(); info.fmiEndPos = in.getEndOfFileMetaInfoPosition(); } catch (IOException e) { e.printStackTrace(); System.err.println("WARNING: Failed to parse " + f + " - skipped."); System.out.print('F'); return; } finally { CloseUtils.safeClose(in); } info.cuid = dcmObj.getString(Tag.MediaStorageSOPClassUID, dcmObj.getString(Tag.SOPClassUID)); if (info.cuid == null) { System.err.println("WARNING: Missing SOP Class UID in " + f + " - skipped."); System.out.print('F'); return; } info.iuid = dcmObj.getString(Tag.MediaStorageSOPInstanceUID, dcmObj.getString(Tag.SOPInstanceUID)); if (info.iuid == null) { System.err.println("WARNING: Missing SOP Instance UID in " + f + " - skipped."); System.out.print('F'); return; } if (suffixUID != null) info.iuid = info.iuid + suffixUID[0]; addTransferCapability(info.cuid, info.tsuid); files.add(info); System.out.print('.'); }
From source file:org.opoo.press.impl.SiteImpl.java
FileFilter buildFilter() { final List<String> includes = config.get("includes"); final List<String> excludes = config.get("excludes"); return new FileFilter() { @Override//from ww w .j av a2s .com public boolean accept(File file) { String name = file.getName(); if (includes != null && includes.contains(name)) { return true; } if (excludes != null && excludes.contains(name)) { return false; } char firstChar = name.charAt(0); if (firstChar == '.' || firstChar == '_' || firstChar == '#') { return false; } char lastChar = name.charAt(name.length() - 1); if (lastChar == '~') { return false; } if (file.isHidden()) { return false; } return true; } }; }
From source file:qupath.lib.gui.tma.TMASummaryViewer.java
public void setInputFile(File file) { if (file == null) return;/* w w w . j a v a2s. c om*/ if (file.getName().toLowerCase().endsWith(PathPrefs.getSerializationExtension())) { ImageData<BufferedImage> imageData = PathIO.readImageData(file, null, null, BufferedImage.class); setTMAEntriesFromImageData(imageData); return; } List<TMAEntry> entriesTemp = new ArrayList<>(); File dir = file.isDirectory() ? file : file.getParentFile(); for (File fileInput : dir.listFiles()) { if (fileInput.isHidden() || fileInput.isDirectory() || !fileInput.getName().toLowerCase().endsWith(".qptma")) continue; parseInputFile(fileInput, entriesTemp); } if (entriesTemp.isEmpty()) { logger.error("No data found for " + file.getAbsolutePath()); return; } setTMAEntries(entriesTemp); stage.setTitle("TMA Results View: " + dir.getName()); }
From source file:org.jwebsocket.plugins.filesystem.FileSystemPlugIn.java
/** * Gets the file list from a given alias an optionally from a sub path. * * @param aUsername The requester client username. * @param aToken/*w ww. ja va 2 s . c o m*/ * @return */ private Token mGetFilelist(WebSocketConnector aConnector, Token aToken) { String lAlias = aToken.getString("alias"); boolean lRecursive = aToken.getBoolean("recursive", false); boolean lIncludeDirs = aToken.getBoolean("includeDirs", false); List<Object> lFilemasks = aToken.getList("filemasks", new FastList<Object>()); String lSubPath = aToken.getString("path", null); Object lObject; String lBaseDir; Token lToken = TokenFactory.createToken(); lObject = mSettings.getAliasPath(lAlias); if (lObject != null) { lBaseDir = (String) lObject; lBaseDir = replaceAliasVars(aConnector, lBaseDir); /* lBaseDir = JWebSocketConfig.expandEnvVarsAndProps(lBaseDir). replace("{username}", aConnector.getUsername()); */ File lDir; if (null != lSubPath) { lDir = new File(lBaseDir + File.separator + lSubPath); } else { lDir = new File(lBaseDir + File.separator); } if (!isPathInFS(lDir, lBaseDir)) { lToken.setInteger("code", -1); lToken.setString("msg", "The path '" + lSubPath + "' is out of the file-system location!"); return lToken; } else if (!(lDir.exists() && lDir.isDirectory())) { lToken.setInteger("code", -1); lToken.setString("msg", "The path '" + lSubPath + "' is not directory on target '" + lAlias + "' alias!"); return lToken; } // IOFileFilter lFileFilter = FileFilterUtils.nameFileFilter(lFilemask); String[] lFilemaskArray = new String[lFilemasks.size()]; int lIdx = 0; for (Object lMask : lFilemasks) { lFilemaskArray[lIdx] = (String) lMask; lIdx++; } IOFileFilter lFileFilter = new WildcardFileFilter(lFilemaskArray); IOFileFilter lDirFilter = null; if (lRecursive) { lDirFilter = FileFilterUtils.directoryFileFilter(); } Collection<File> lFiles = FileUtils.listFilesAndDirs(lDir, lFileFilter, lDirFilter); List<Map> lFileList = new FastList<Map>(); File lBasePath = new File(lBaseDir); MimetypesFileTypeMap lMimesMap = new MimetypesFileTypeMap(); String lRelativePath; for (File lFile : lFiles) { if (lFile == lDir // we don't want directories to be returned // except explicitely requested || (!lIncludeDirs && lFile.isDirectory())) { continue; } Map<String, Object> lFileData = new FastMap<String, Object>(); String lFilename = lFile.getAbsolutePath().replace(lBasePath.getAbsolutePath() + File.separator, ""); // we always return the path in unix/url/java format String lUnixPath = FilenameUtils.separatorsToUnix(lFilename); int lSeparator = lUnixPath.lastIndexOf("/"); if (lSeparator != -1) { lFilename = lUnixPath.substring(lSeparator + 1); lRelativePath = lUnixPath.substring(0, lSeparator + 1); } else { lRelativePath = ""; } lFileData.put("relativePath", lRelativePath); lFileData.put("filename", lFilename); lFileData.put("size", lFile.length()); lFileData.put("modified", Tools.DateToISO8601(new Date(lFile.lastModified()))); lFileData.put("hidden", lFile.isHidden()); lFileData.put("canRead", lFile.canRead()); lFileData.put("canWrite", lFile.canWrite()); lFileData.put("directory", lFile.isDirectory()); lFileData.put("mime", lMimesMap.getContentType(lFile)); if (lAlias.equals(PRIVATE_ALIAS_DIR_KEY)) { lFileData.put("url", getString(ALIAS_WEB_ROOT_KEY, ALIAS_WEB_ROOT_DEF) // in URLs we only want forward slashes + FilenameUtils.separatorsToUnix(lFilename)); } lFileList.add(lFileData); } lToken.setList("files", lFileList); lToken.setInteger("code", 0); lToken.setString("msg", "ok"); } else { lToken.setInteger("code", -1); lToken.setString("msg", "No alias '" + lAlias + "' defined for filesystem plug-in"); } return lToken; }
From source file:com.lfv.lanzius.server.LanziusServer.java
public void menuChoiceLoadExercise() { if (isSwapping) return;//from ww w . j a v a2 s . co m log.info("Menu: Load exercise"); JFileChooser fc = new JFileChooser("data/exercises"); fc.setDialogTitle("Load exercise..."); fc.setMultiSelectionEnabled(false); fc.setFileFilter(new FileFilter() { public boolean accept(File f) { return !f.isHidden() && (f.isDirectory() || f.getName().endsWith(".xml")); } public String getDescription() { return "Exercise (*.xml)"; } }); int returnVal = JFileChooser.APPROVE_OPTION; if (Config.SERVER_AUTOLOAD_EXERCISE == null) returnVal = fc.showOpenDialog(frame); if (returnVal == JFileChooser.APPROVE_OPTION) { //File file; if (Config.SERVER_AUTOLOAD_EXERCISE == null) exerciseFile = fc.getSelectedFile(); else exerciseFile = new File(Config.SERVER_AUTOLOAD_EXERCISE); log.info("Loading exercise " + exerciseFile); if (exerciseFile.exists()) { loadExercise(exerciseFile); } else JOptionPane.showMessageDialog(frame, "Unable to load exercise! File not found!", "Error!", JOptionPane.ERROR_MESSAGE); } }