Java 8 FileSystemView - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 FileSystemView class.

This code example shows how to use the following methods:isDrive, isFileSystemRoot, isFloppyDrive, isRoot
    /** 
     * Checks whether the given File is a leaf node.  For our purposes, a leaf 
     * node must be a file and not an alias to a folder. 
     */ 
    private static boolean isLeaf(File file) {
        if (FileSystemView.isDrive(file )         ||
            FileSystemView.isFileSystemRoot(file) ||
            FileSystemView.isFloppyDrive(file)    ||
            FileSystemView.isRoot(file)
        ) { 
            return false; 
        } 
        file = FileUtil.isFolder( file );
        return file == null;
/* 
        if ( file == null ) 
            return true; 
        if ( file instanceof SmartFolder ) { 
            // 
            // Always consider a SmartFolder to be a non-leaf node because 
6
CodeRank
This code example shows how to use the following methods:getSystemIcon
                // the file effectively exists when the icon is requested. 
                // So the workaround here is to catch exceptions and 'silence' System.err output during the call. 
 
                errOut.setSilenced(true);
 
                return fileSystemView.getSystemIcon(javaIoFile);
            } 
            else { 
                return fileChooser.getIcon(javaIoFile);
            } 
        } 
        catch(Exception e) {
            LOGGER.info("Caught exception while retrieving system icon for file {}", javaIoFile.getAbsolutePath(), e);
            return null; 
        } 
        finally { 
            if(fileSystemView!=null)
                errOut.setSilenced(false);
        } 
    } 
3
CodeRank
This code example shows how to use the following methods:getDefaultDirectory
            LauncherStub.class.getCanonicalName());
 
    private static File getFileChooseDefaultDir() {
        JFileChooser chooser = new JFileChooser();
        FileSystemView fsv = chooser.getFileSystemView();
        return fsv.getDefaultDirectory();
    } 
 
    private static File getUserLauncherDir() {
        String osName = System.getProperty("os.name").toLowerCase();
        if (osName.contains("win")) {
            return new File(getFileChooseDefaultDir(), "SKMCLauncher");
        } else { 
            return new File(System.getProperty("user.home"), ".skmclauncher");
        } 
    } 
 
    private static boolean isPortableMode() { 
        return new File("portable.txt").exists();
    } 
3
CodeRank
This code example shows how to use the following methods:getSystemIcon
			JPanel newPanel = new JPanel();
			 
			JCheckBox checkbox = node.getCheckbox();
			checkbox.setSelected(node.getSelected());
 
            try { setIcon(fsv.getSystemIcon(userObject.file)); }
            catch (Exception ignored) {}
			 
			newPanel.setBackground(nodeComponent.getBackground());
			checkbox.setBackground(nodeComponent.getBackground());
			 
			GridBagLayout gbl = new GridBagLayout();
			addComponent(gbl, newPanel, checkbox, null, null, null, 0, 0, 1, 1, 0, 0, 0, 0);
			addComponent(gbl, newPanel, nodeComponent, GridBagConstraints.HORIZONTAL, null, new Insets(1, 2, 0, 0), 1, 0, 1, 1, 1, 0, 0, 0);
			 
			if (userObject.fileCount > 0) {
				JLabel label = new JLabel("(" + userObject.fileCount + " file" + (userObject.fileCount > 1 ? "s" : "") + ")");
				addComponent(gbl, newPanel, label, null, null, new Insets(1, 2, 0, 0), 2, 0, 1, 1, 0, 0, 0, 0);
			} 
			return newPanel;
2
CodeRank
See Code Examples for Java 8 FileSystemView Methods: