public void write(OutputStream os) throws Exception { BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os)); String str = toString(); bw.write(str, 0, str.length()); bw.newLine(); bw.close(); }
private void write(String msg) { SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss"); try { BufferedWriter bw = new BufferedWriter(new FileWriter(filePath, true)); bw.write("[" + formatter.format(new java.util.Date()) + "] " + msg); bw.newLine(); bw.close(); } catch (IOException e) { e.printStackTrace(); } }
public void ecrireFichier(String chemin, Vector<Integer> highScore) { try { FileWriter fw = new FileWriter(chemin, false); BufferedWriter output = new BufferedWriter(fw); for (int i = 0; i < highScore.size(); i++) { output.write(highScore.get(i).toString()); output.newLine(); } output.flush(); output.close(); } catch (IOException e) { e.printStackTrace(); } }