Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. public static void EscriureFitxer(String nom,String cognom1,String cognom2,String dni,File FILE_NAME,ArrayList<Alumne> list){
  2. Alumne a = new Alumne (nom,cognom1,cognom2,dni);
  3. list.add(a);
  4. ObjectOutputStream objectOutput = null;
  5. try {
  6. objectOutput = new ObjectOutputStream(new FileOutputStream(FILE_NAME));
  7. objectOutput.writeObject(list);
  8.  
  9. System.out.println("S'ha generat el fitxer " + FILE_NAME);
  10.  
  11. } catch (FileNotFoundException e) {
  12. e.printStackTrace();
  13. } catch (IOException e) {
  14. e.printStackTrace();
  15. } finally {
  16. if(objectOutput != null) {
  17. try {
  18. objectOutput.close();
  19. } catch (IOException ignored) {
  20. }
  21. }
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement