Writing and reading enums in files | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

26th Nov 2020, 1:42 PM
Michel Ghaith
Michel Ghaith - avatar
1 Answer
+ 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); }
28th Nov 2020, 9:10 PM
Scripting_boom - avatar