I made a FileOutputStream, which saves an arraylist full of String[]'s to an xml file. The problem is, that when I load the file, I can only load it as a String. The Strings are some weird codes likes:
[Ljava.lang.String;@75a7d0f4
I need help to, save (or load) the String[]'s so I can call them probably
And, in the load method, I need to pass all the data to the addSong() method with a loop?
Code:
public class Songs {
List<String[]> songs = new ArrayList<String[]>();
public void addSong(String s, String a, String yt){
String[] songarray= new String[3];
songarray[0] = s;
songarray[1] = a;
songarray[2] = yt;
songs.add(songarray);
}
public void editSong(int i, String s, String a, String yt){
String[] editsongarray = new String[3];
editsongarray[0] = s;
editsongarray[1] = a;
editsongarray[2] = yt;
songs.remove(i);
songs.add(i,editsongarray);
}
public void removeSong(int i){
songs.remove(i);
}
public String[] getList(int i){
String[] j = songs.get(i);
return j;
}
public void save() throws FileNotFoundException{
PrintWriter pw = new PrintWriter(new FileOutputStream("C:\\Applications\\songs.xml"));
for(String[] x:songs)
pw.println(x);
pw.close();
}
public void load()throws FileNotFoundException{
FileInputStream in = new FileInputStream("C:\\Applications\\songs.xml");
Scanner scan = new Scanner(in);
String x = scan.next();
//String[] x = scan.next(); doesnt works
System.out.println(x);
}
}