diff options
author | Clyhtsuriva <aimeric@adjutor.xyz> | 2020-12-11 10:06:34 +0100 |
---|---|---|
committer | Clyhtsuriva <aimeric@adjutor.xyz> | 2020-12-11 10:06:34 +0100 |
commit | 67db3838608308576ef28c0259dc0584673d27a8 (patch) | |
tree | 611f0da23402dff667712e271f6ef9447354f4cd /Song.java | |
parent | 532cd1e395a637a5e507bc3687a4a64e50e55b30 (diff) |
Getting serialization working with a song
Diffstat (limited to 'Song.java')
-rw-r--r-- | Song.java | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -1,5 +1,8 @@ public class Song extends MusicalElement{ + + private static final long serialVersionUID = 2112880640160601826L; private String artist, genre; + public Song(String title, int duration, String content, String artist, Genre genre) { super(title, duration, content); this.artist=artist; @@ -12,14 +15,16 @@ public class Song extends MusicalElement{ public void setGenre(Genre genre){this.genre=genre.name();} public String toString() { - return getTitle()+";"+getDuration()+";"+getContent()+";"+artist+";"+genre; + return "Title : "+getTitle()+"\nDuration : "+getDuration()+"\nContent : "+getContent()+"\nArtist : "+getArtist()+"\nGenre : "+getGenre(); +// return getTitle()+";"+getDuration()+";"+getContent()+";"+getArtist()+";"+getGenre(); } - public void save(){ +/* public static void save(){ + String filename="songs.csv"; try { //Saving of object in a file - FileOutputStream file = new FileOutputStream(songs.csv); + FileOutputStream file = new FileOutputStream(filename); ObjectOutputStream out = new ObjectOutputStream(file); // Method for serialization of object @@ -36,7 +41,7 @@ public class Song extends MusicalElement{ { System.out.println("IOException is caught"); } - } + }*/ } |