How can I get the icon to display for a file from a Java app?

desktop, icons, java

Solution

There is some example here. The relevant code would be:

FileSystemView view = FileSystemView.getFileSystemView();    
Icon icon = view.getSystemIcon(file);    

Edit (included comment) The official help page is here.

Problem

Is it possible from a Java desktop app to find the icon to display for a given file, perhaps based on it's mime type? Specifically I want to ask the host OS for the icon to display so it can match what the user would expect to see.

Original source