I select a file using jfilechoser

private File file; public void actionPerformed(ActionEvent e) { JFileChooser fileopen = new JFileChooser(); ret = fileopen.showDialog(null, "Открыть файл"); file = fileopen.getSelectedFile(); label.setText(file.getName()); } 

Then I want to use, for example, FileWriter to write data to a file that will have a similar path. How to do it right? Tried like this, did not work:

 File Filenew = new File(file + "копия"); 

    1 answer 1

    See File methods. Docs link

      File Filenew = new File(file.getAbsoluteFile().getParent() + "\копия");