+ 1
Writing and reading enums in files
I am writing a java game And i need to save data on my file Some of this data are enums How can i write it and read it in a valid case My file object is File gamefile=new File(filepath); I read from it using a scanner
1 Odpowiedź
+ 1
u could for example always save the players cordinates on line 1 & 2 and the level on line 3
Example:
[Save.txt]
40
20
3
[Function]
void loadData(String fileData){
player.x = fileData.getline(1);
player.y = fileData.getline(2);
player.level = fileData.getline(3);
}