10 Mart 2010

Write Text to File with BufferedWriter

BufferedWriter bw = null;
try {
bw = new BufferedWriter(new FileWriter(PASSWORD_HISTORY_FILE,true));
bw.newLine();
bw.write(user);
}
catch(FileNotFoundException fnfe){
System.out.println("Can't open passwordHistory.txt");
}
catch(Exception e){
e.printStackTrace();
}finally {
//Close the BufferedWriter
try {
if (bw != null) {
bw.flush();
bw.close();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}

Hiç yorum yok: