0
[Solved!]How can i save data from an app in java?
Hey there So i'm making an application for next school year for practice. Like a planner of some kind. it's gonna keep me organised aswell. Right now i have a notes tab. But i wonder how i can save the thing i type in there when i close the app and reopen it. Do i have to make an entire database or? cuz im still learning the very very very basics of that xd. its going to have a calender too, schedule,.. lots of stuff, but i wanna start if i can even save the note tab lmao. And i have a login screen, but that doesn't really need saving.
5 ответов
+ 1
i think ill have to try something else.
Serialization it is i suppose.
0
https://www.youtube.com/watch?v=nQsu37G2rF8
looks easy enough
0
i take that back
public void loadData() {
try {
BufferedReader br = new BufferedReader(new FileReader("saveData.txt"));
notes = br.readLine();
br.close();
}
catch(Exception e){
}
NotesText.setText(notes);
}
this doesn't work...idk why. i get no errors xd.
0
save Save = new save();
Save.age = 50;
Save.name = "JOE";
String fileName = "data.bin";
try {
ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream(fileName));
os.writeObject(Save);
os.close();
System.out.println("test");
} catch(IOException e) {
e.printStackTrace();
}
System.out.println("Done writing!");
couldn't make this work either...jesus. rip me
0
nvm, the file was saved in a different folder