Java examples for File Path IO:File Attribute
Getting the File-Type Name of a File
import java.io.File; import javax.swing.JFileChooser; public class Main { public static void main(String[] argv) { JFileChooser chooser = new JFileChooser(); // Create a File instance of the file File file = new File("filename.txt"); // Get the file type name String fileTypeName = chooser.getTypeDescription(file); System.out.println(fileTypeName); // Text Document }//from w w w . j a v a 2s . c o m }