title: llegal escape character followed by a space
body: <p>I'm writing a bit of code to run a shell script using process that loads and runs a file in terminal. The problem I'm having is getting the filename to be recognised by terminal due to the spaces, for example : </p>
  
  <pre><code>"$ ./run_file.sh foo bar.ss" 
  </code></pre>
  
  <p>should be run in terminal as </p>
  
  <pre><code>"$ ./run_file.sh foo\ bar.ss"
  </code></pre>
  
  <p>Heres the code to change it replace it: </p>
  
  <pre><code>JPanel panel1 = new JPanel();
  JButton button = new JButton("Run");
  button.setAlignmentX( Component.CENTER_ALIGNMENT);
  
  button.addActionListener(new ActionListener(){
  
      public void actionPerformed(ActionEvent event){
  
          run();
  
      }
  
  });
  //button.setAlignmentX(0.5);
  panel1.add(button);
  panel1.add(Box.createVerticalGlue());
  panel1.add(button);
  
  menuB = new JMenuBar();
  
  JMenu dropD = new JMenu("File");
  menuB.add(dropD);
  
  JMenuItem loadR = new JMenuItem("Load file");
  JMenuItem quit = new JMenuItem("Quit");
  dropD.add(loadR);
  dropD.add(quit);
  loadR.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent event) {
              JFileChooser fileopen = new JFileChooser();
  
              int r= fileopen.showDialog(panel, "Load file");
  
              if (r == JFileChooser.APPROVE_OPTION) {
                  File file = fileopen.getSelectedFile();
                  String string = file.toString();
                  string = string.replaceAll(" ", "\ ");
                  //String output = aa.replaceAll("/",Character.toString(File.separatorChar));
                  System.out.println(string);
                  loadFile = file;
          }
  
         }
    });
  </code></pre>
  
  <p>I have been tried using String.replaceAll but get </p>
  
  <pre><code>java:66: illegal escape character
  </code></pre>
  
  <p>i realise that I can use File.separatorChar :</p>
  
  <pre><code>string = string.replaceAll(" ", Character.toString(File.separatorChar)+" ");
  </code></pre>
  
  <p>but this doesn't seem to replace anything...
  Any help would be much appreciated.</p>
  
  <p>Thanks</p>