aboutsummaryrefslogtreecommitdiff
path: root/jMusicHub.java
diff options
context:
space:
mode:
Diffstat (limited to 'jMusicHub.java')
-rw-r--r--jMusicHub.java28
1 files changed, 26 insertions, 2 deletions
diff --git a/jMusicHub.java b/jMusicHub.java
index 2cbedc3..26fe9b6 100644
--- a/jMusicHub.java
+++ b/jMusicHub.java
@@ -1,4 +1,5 @@
import java.util.*;
+import java.io.*;
/** <h1>jMusicHub</h1>
*
@@ -120,10 +121,33 @@ public class jMusicHub {
break;
case "s":
for (Song s: songs){
- s.save();
- }
+ String filename = "songs.csv";
+
+ // Serialization
+ try {
+
+ // Saving of object in a file
+ FileOutputStream file = new FileOutputStream
+ (filename);
+ ObjectOutputStream out = new ObjectOutputStream
+ (file);
+
+ // Method for serialization of object
+ out.writeObject(s);
+
+ out.close();
+ file.close();
+ System.out.println("Object has been serialized\n"
+ + "Data before Deserialization.");
+ System.out.println(s);
+ }
+ catch (IOException ex) {
+ System.out.println("IOException is caught");
+ }
+ }
break;
+
default :
System.out.println("Unknown command. Type h for help.");