aboutsummaryrefslogtreecommitdiff
path: root/Song.java
diff options
context:
space:
mode:
Diffstat (limited to 'Song.java')
-rw-r--r--Song.java25
1 files changed, 24 insertions, 1 deletions
diff --git a/Song.java b/Song.java
index c4d1fc3..ecbb1eb 100644
--- a/Song.java
+++ b/Song.java
@@ -1,4 +1,4 @@
-public class Song extends MusicalElement {
+public class Song extends MusicalElement{
private String artist, genre;
public Song(String title, int duration, String content, String artist, Genre genre) {
super(title, duration, content);
@@ -15,5 +15,28 @@ public class Song extends MusicalElement {
return getTitle()+";"+getDuration()+";"+getContent()+";"+artist+";"+genre;
}
+ public void save(){
+ try
+ {
+ //Saving of object in a file
+ FileOutputStream file = new FileOutputStream(songs.csv);
+ ObjectOutputStream out = new ObjectOutputStream(file);
+
+ // Method for serialization of object
+ out.writeObject(this);
+
+ out.close();
+ file.close();
+
+ System.out.println("Object has been serialized");
+
+ }
+
+ catch(IOException ex)
+ {
+ System.out.println("IOException is caught");
+ }
+ }
+
}