Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. public void escribir(String mensaje) {
  2. FileWriter fichero = null;
  3. PrintWriter pw = null;
  4.  
  5. if()
  6.  
  7. try {
  8. fichero = new FileWriter("./prueba.txt");
  9. pw = new PrintWriter(fichero);
  10. pw.append(mensaje);
  11. JOptionPane.showMessageDialog(null,"Texto Guardado");
  12.  
  13. } catch (Exception e) {
  14. e.printStackTrace();
  15. } finally {
  16. try {
  17. // Nuevamente aprovechamos el finally para
  18. // asegurarnos que se cierra el fichero.
  19. if (null != fichero) {
  20. fichero.close();
  21. }
  22. } catch (Exception e2) {
  23. e2.printStackTrace();
  24. }
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement