4 Replies Latest reply: Apr 24, 2013 9:23 AM by rp0428 RSS

    How to get the file path of selected file using JFileChooser

    777684
      Hi All,
      I am trying to store the file on my FTP server after selecting the file from the user workstation using JFileChooser. But I am not able to write the file on FTP server or on user local machine where application is running. I am new to this FTP server coding. Can anyone help me in this.
      This is the code I wrote on button click user will able to select the file:

      String filename1;
      File file;
      JFileChooser fc = new JFileChooser();
      fc.showOpenDialog(this);
      file = fc.getSelectedFile();
      filename1 = file.getPath();
      txtFilePath.setText(filename1);

      Below is the code to write the file on my local machine first:

      BufferedWriter outFile = new BufferedWriter( fileName ) );
      outFile.write();
      outFile.flush( );
      outFile.close( );

      Any help will be greatly appriciated