Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void load(){
- File save = new File("<location of save>");
- String gameson = null;
- if (save.exists() && !save.isDirectory()) {
- try(Scanner scanner = new Scanner("<location of save>")){
- String temp = scanner.nextLine();
- while (scanner.hasNext()) {
- temp = temp + scanner.nextLine();
- }
- gameson = temp;
- } catch (Exception e) {
- e.printStackTrace();
- }
- Gson gson = new GsonBuilder().create();
- savedGame = gson.fromJson(gameson, me.minerobber9000.ircadventure.game.Game.class);
- } else {
- System.out.println("No save to load.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment