import java.io.File;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import sun.awt.shell.ShellFolder;
public class Main {
public static void main(String[] argv) throws Exception {
File file = new File("filename.txt");
ShellFolder sf = ShellFolder.getShellFolder(file);
Icon icon = new ImageIcon(sf.getIcon(true), sf.getFolderType());
}
}