title: Get the type of selected file by JFileChooser
body: <p>I am writing a program to select file from the <code>JFileChooser</code>. How can I get the file type (e.g. is that file is "<strong>.txt</strong>" or "<strong>.html</strong>" of "<strong>.dat</strong>", etc.. )<Br><br>
  I have the following code. what should i have to add extra lines?</p>
  
  <pre><code>JFileChooser choice = new JFileChooser();
  int option = choice.showOpenDialog(this);
  if (option == JFileChooser.APPROVE_OPTION)
  {
       String path=choice.getSelectedFile().getAbsolutePath();
       String filename=choice.getSelectedFile().getName();
       System.out.println(path);
       listModel.addElement(path);
       System.out.println(filename);
  }
  </code></pre>