title: How do I get the file name of the file opened by JFilechooser?
body: <p>Currently I have</p>
  
  <pre><code>    final JFileChooser fc = new JFileChooser("src\\MovieBoxOffice\\MovieFiles");
          int returnVal = fc.showOpenDialog(openJButton);
          if(returnVal == JFileChooser.APPROVE_OPTION)
          {
          try
          {
               File selectedFile = fc.getSelectedFile();
               String filename = selectedFile.getAbsolutePath();
  (....rest of code)
  </code></pre>
  
  <p>so filename is the FULL path. 
  It looks something like</p>
  
  <pre><code>F:\Project3\src\MovieBoxOffice\MovieFiles\November2015.txt
  </code></pre>
  
  <p>I want it to end up getting just</p>
  
  <pre><code>November2015.txt
  </code></pre>
  
  <p>It'd be even better if it's just November2015</p>
  
  <p>I can't seem to find a method that just straight up gets the file name.</p>
  
  <p>I tried using the split method.</p>
  
  <pre><code>String[] str = filename.split("\\");
  </code></pre>
  
  <p>so I can get the last item of the array, which would be the file name.
  But that line of code is throwing exceptions:</p>
  
  <pre><code>Exception in thread "AWT-EventQueue-0" java.util.regex.PatternSyntaxException: Unexpected internal error near index 1
  </code></pre>
  
  <p>How can I get just the base filename?</p>