title: Using JFileChooser to read a file name
body: <p>I am using the File input stream to input a file</p>
  
  <hr>
  
  <pre><code>String filename="D:\\abc.txt";
  File file = new File(filename);
  </code></pre>
  
  <hr>
  
  <p>It works fine up till now. Now I want to input the file name using <code>JFileChooser</code> and then do the same. But <code>JFileChooser</code> returns a string like this <code>D:\abc.txt</code>. My code is as follows</p>
  
  <hr>
  
  <pre><code>public static String fileChose()
  {
      JFileChooser fc= new JFileChooser();
      int ret = fc.showOpenDialog(null);
  
      if (ret== JFileChooser.APPROVE_OPTION) 
      {
          File file = fc.getSelectedFile();
          String filename= file.getAbsolutePath();
          return filename;
      }
      else
          return null;
  }
  </code></pre>
  
  <hr>
  
  <p>The problem is with needing to filenames separated by <code>\\</code> instead of <code>\</code>. Can't I directly input the filename from JFileChooser in such a manner so as to directly use it as an argument in </p>
  
  <hr>
  
  <pre><code>File file = new File(Classname.fileChose());
  </code></pre>