need help with writing to file.
hi. I have one problem. my writen program code don't write to file. can anyone tell why.
class metodai{
public PrintWriter fl_ras(File fl_pav)throws IOException{
returnnew PrintWriter(new FileWriter(fl_pav));
}
//.....
publicvoid Saugo(PrintWriter R_wr, JComboBox ps){
// for output using R_wr.print("String wich I need to save to file");
//also have tried R_wr.println(); no much use
}
}
//.....
publicclass Pradziaextends JFrame{
//.....
Metodai met =new Metodai();
//.....
class sv_flimplements ActionListener{// taking action when button to save file is pressed
publicvoid actionPerformed(ActionEvent e){
try{
JFileChooser Fc =new JFileChooser();
Fc.setDialogTitle("Pasirinkite faila kuriame bus issaugoti rezultatai");
int r = Fc.showSaveDialog(Pradzia.this);
if (r == JFileChooser.APPROVE_OPTION){//kai pasirenkama 'Save'
R_wr = met.fl_ras(Fc.getSelectedFile());
met.Saugo(R_wr, psr);
}elseif (r == JFileChooser.CANCEL_OPTION){//kai pasirenkama 'Cancel'
txt.append("\n\nIssaugojimo faile atsisakyta\n--> Duomenys neissaugoti");
}elseif(r == JFileChooser.ERROR_OPTION){
txt.append("\n\n!!! --> nepasirinktas rezultatu failas arba klaida ji pasirenkant");
}
}catch (IOException ex){
txt.append("\n\n!!! --> Klaida atidarant rezultatu faila");
}
}
}
//.....
}
P.S. file was created but empty.

