Wednesday, March 6, 2013

Detect Home folder using java

import java.io.*;
import javax.swing.filechooser.*;
public class DriveTypeInfo {

    public static void main(String[] args)
    {
        FileSystemView fsv = FileSystemView.getFileSystemView();
        System.out.println("Home directory: " + fsv.getHomeDirectory());
        File[] f = File.listRoots();
        for (File aF : f) {
                System.out.println("Drive: " + aF);
                System.out.println("Display name: " + fsv.getSystemDisplayName(aF));
        }
    }
}

No comments: