Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8098653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:08:26+00:00 2026-06-05T22:08:26+00:00

so i am currently making a game (a huge one over 3500 lines of

  • 0

so i am currently making a game (a huge one over 3500 lines of code) and when programing the saving feature of the game i ran into an error.it saves just fine but when i try to load one of the files that i saved the game to it returns an error:

Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: ""
    at java.lang.NumberFormatException.forInputString(Unknown Source)
    at java.lang.Integer.parseInt(Unknown Source)
    at java.lang.Integer.parseInt(Unknown Source)
    at com.torstein.Mars_Settlement.States.Building.Parse(Building.java:56)
    at com.torstein.Mars_Settlement.Managers.SavingManager.Load(SavingManager.java:102)
    at com.torstein.Mars_Settlement.SLGUI$2.actionPerformed(SLGUI.java:155)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)

and so on…

it is basicly saying that the Scanner i use to scan the file is returning “”. i have checked over source code many times but i cant get i to work. here is the SavingManager Class:

package com.torstein.Mars_Settlement.Managers;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Formatter;
import java.util.Scanner;

import com.torstein.Mars_Settlement.Bases;
import com.torstein.Mars_Settlement.Connection;
import com.torstein.Mars_Settlement.Main;
import com.torstein.Mars_Settlement.Eneties.CarEnety;
import com.torstein.Mars_Settlement.Eneties.LightGunnerEntity;
import com.torstein.Mars_Settlement.Eneties.Pepole;
import com.torstein.Mars_Settlement.Eneties.Plant;
import com.torstein.Mars_Settlement.Eneties.TankEntity;
import com.torstein.Mars_Settlement.States.Building;
import com.torstein.Mars_Settlement.States.GroundState;

public class SavingManager {

    public static void Save(String Path){
        Main m = Main.UseThis;
        File txt = new File(Path);
        txt.delete();
        Formatter f = null;
        try {
            f = new Formatter(Path);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        f.format("%d%n",m.pepoleOut);
        for(Bases b : m.bases)
            f.format(b.toString()+"%n");
        f.format(":%n");
        f.format(m.Fusion+"%n");
        f.format(m.Compact+"%n");
        f.format(m.Money+"%n");
        f.format(m.Water+"%n");
        f.format(m.Energy+"%n");
        f.format(m.Food+"%n");
        f.format(m.Venus+"%n");
        for(int x = 0;x<20;x++)
            for(int y = 0;y<20;y++)
                f.format(m.stateG[x][y].T+"%n");
        for(int x = 0;x<20;x++)
            for(int y = 0;y<20;y++)
                f.format(m.stateB[x][y].toString()+"%n");
        f.format(m.Terraformed+"%n");

        for(CarEnety b : m.cars)
            f.format(b.toString()+"%n");
        f.format(":%n");

        for(Pepole b : m.Pepole)
            f.format(b.toString()+"%n");
        f.format(":%n");

        for(Plant b : m.plants)
            f.format(b.toString()+"%n");
        f.format(":%n");

        for(Connection b : m.Connections)
            f.format(b.toString()+"%n");
        f.format(":%n");
        for(TankEntity b : m.Tanks)
            f.format(b.toString()+"%n");
        f.format(":%n");
        for(LightGunnerEntity b : m.LightGunners)
            f.format(b.toString()+"%n");
        f.format(":%n");

        f.close();
    }
    public static void Load(String Path){
        final Main m = Main.UseThis;
        m.Contiuecapable=true;
        m.Treset();
        Scanner scan = null;
        try {
            scan = new Scanner(new File(Path));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        String cln;
        m.pepoleOut = scan.nextInt();
        while(!(cln = scan.nextLine()).startsWith(":"))
            if(Bases.parseBase(cln)!=null)m.bases.add(Bases.parseBase(cln));
        m.Fusion = scan.nextBoolean();
        m.Compact = scan.nextBoolean();
        m.Money = scan.nextInt();
        m.Water = scan.nextInt();
        m.Energy = scan.nextInt();
        m.Food = scan.nextInt();
        m.Venus = scan.nextBoolean();
        for(int x = 0;x<20;x++)
            for(int y = 0;y<20;y++)
                m.stateG[x][y]=GroundState.Parse(scan.nextInt());


        for(int x = 0;x<20;x++)
            for(int y = 0;y<20;y++)
            {

                m.stateB[x][y]= Building.Parse(scan.nextLine());
                if(m.stateB[x][y].index==6)
                    m.addHouseSpirit(x,y);
            }

        m.Terraformed = scan.nextBoolean();
        while(!(cln = scan.nextLine()).startsWith(":"))
            if(CarEnety.Parse(cln)!=null)m.cars.add(CarEnety.Parse(cln));
        while(!(cln = scan.nextLine()).startsWith(":"))
            if(Pepole.Parse(cln)!=null)m.Pepole.add(Pepole.Parse(cln));
        while(!(cln = scan.nextLine()).startsWith(":"))
            if(Plant.Parse(cln)!=null)m.plants.add(Plant.Parse(cln));
        while(!(cln = scan.nextLine()).startsWith(":"))
            if(Connection.Parse(cln)!=null)m.Connections.add(Connection.Parse(cln));
        while(!(cln = scan.nextLine()).startsWith(":"))
            if(TankEntity.Parse(cln)!=null)m.Tanks.add(TankEntity.Parse(cln));
        while(!(cln = scan.nextLine()).startsWith(":"))
            if(LightGunnerEntity.Parse(cln)!=null)m.LightGunners.add(LightGunnerEntity.Parse(cln));

        scan.close();
    }

}

File content that im trying to parse:

0
R:4:4:0:false
:
false
false
1000
1000
500
1000
false
0
0
0
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0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
0:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
-1:100:0:1
false
:
:
:
:
:
:

Building.Parse:

public static Building Parse(String parsef){

        int id = Integer.parseInt(parsef.split(":")[0]);
        Building b =id == -1 ? No :
        id == 0 ? Base :
        id == 1 ? UranCollectorBase :
        id == 2 ? IceCollectorBase :
        id == 3 ? NuclearReactor :
        id == 4 ? House :
        id == 5 ? IceMeltor :
        id == 6 ? GunHouse :
        id == 7 ? ResearchCenter :
        id == 8 ? GBase :
        id == 9 ? SBase :
        id == 10 ? MBase :
        id == 11 ? FlowerCollector :
        id == 12 ? WindMill :
        id == 13 ? VechleProduser :
        id == 14 ? OBase :
        No;
        b.health = Integer.parseInt(parsef.split(":")[1]);
        b.Tanks = Integer.parseInt(parsef.split(":")[2]);
        b.lookfor=carStates.Parse(Integer.parseInt(parsef.split(":")[3]));
        return b;
    }

if there is anything else you will have to need to fix this error please say so. Thanks for your time. Torstein.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T22:08:28+00:00Added an answer on June 5, 2026 at 10:08 pm

    I think, when statement scan.nextInt() in for loop { GroundState.Parse(scan.nextInt()) } executed last time , the file reading pointer is at the end of the line. Then call to nextLine() will return “” (empty string). So what you need to do is just skip this particular empty string from processing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently making a game where the player will click on one of his
Im making a .bat game, and currently when putting in a command the code
I am trying to create a game server, and currently, I am making it
I'm currently making a PHP-program that solves equations. I've divided the input equation into
I'm currently making a game in XNA4 for Windows phone 7, and I'd like
I am currently making a fullscreen game and I want to be able to
I am making simple graphical game in WinForms and currently I would like to
I am currently in the process of making a snake game using VB.NET... I
I'm currently making a pacman game in java. I have a question about the
I am currently making this text-based rpg game with a simple GUI. I was

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.