Using the FileSystemView Class : FileSystemView « File « Java Tutorial






public abstract class FileSystemView {
  public FileSystemView();  // Properties
  // Properties
  public File getDefaultDirectory();
  public File getHomeDirectory();
  public File[] getRoots();
  // Class Methods
  public static FileSystemView getFileSystemView();
  // Other Methods
  public File createFileObject(File directory, String filename);
  public File createFileObject(String path);
  protected File createFileSystemRoot(File file);
  public abstract File createNewFolder(File containingDir) throws IOException;
  public File getChild(File parent, String filename);
  public File[] getFiles(File directory, boolean useFileHiding);
  public File getParentDirectory(File file);
  public String getSystemDisplayName(File file);
  public Icon getSystemIcon(File file);
  public String getSystemTypeDescription(File file);
  public boolean isComputerNode(File file);
  public boolean isDrive(File file);
  public boolean isFileSystem(File file);
  public boolean isFileSystemRoot(File file);
  public boolean isFloppyDrive(File file);
  public boolean isHiddenFile(File file);
  public boolean isParent(File folder, File file);
  public boolean isRoot(File file);
  public Boolean isTraversable(File file);
}
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileSystemView;

public class UsingFileSystemView {

  public static void main(String[] a) {

    JFileChooser chooser = new JFileChooser();

    FileSystemView view = chooser.getFileSystemView();

    System.out.println(view.getDefaultDirectory());

  }

}








11.56.FileSystemView
11.56.1.Using the FileSystemView Class