Bom dia alguem me poderá dizer porque é que o seguinte codigo grava sempre na pasta onde esta o jar e nao na pasta do filedialog?
Ando ha horas e n consigo perceber :S
Obrigado
public static void save()
{
FileDialog d = new FileDialog(Aluno.jFrame, “Guardar Programa”, FileDialog.SAVE);
String Directorio = Aluno.IP+"\Servidor\Programas";
d.setDirectory( Directorio );
d.show();
d.setFilenameFilter(
new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.endsWith(".txt");
}
}
);
String filename = d.getFile();
File f = new File(filename);
if (filename != null) {
try {
FileOutputStream fs = new FileOutputStream(f);
PrintStream ps = new PrintStream( fs );
ps.close();
fs.close();
} catch (IOException ex) {
System.out.println(ex.toString());
}
}
try {
//FileWriter outStream = new FileWriter(fileName);
BufferedWriter outStream = // Cria e abre a stream
new BufferedWriter(new FileWriter(filename));
outStream.write(Aluno.EditorProgramaTextArea.getText()); // Escreve na stream
outStream.close(); // Fecha a stream
} catch (IOException e) {
Aluno.EditorProgramaTextArea.setText("IOerror: " + e.getMessage() + "\n");
e.printStackTrace();
}
}
}