If I save a file like test.csv and open it, JFileChooser will see it like test.cvs. When I am going to save it again it adds csv so i'm getting test.csv.csv and so on. I know it has something to do with FileWriter because I added extension to a file like:
File fajl = new File (fc.getSelectedFile()+".csv");
Is there any way to remove extension when file is opened, and again when it is saved, i wont get test.csv.csv?
I tryed with endsWith and no luck.
This solved it for me. I used Tom van der Woerdt solution with slight modification:
String s = fc.getSelectedFile().toString();
int p = s.lastIndexOf('.');
if(p>0){ s=s.substring(0,p);System.out.print(s);}
fajl = new File (s+".csv");
System.out.print is there just to test output name of the file.