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 7407747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:46:46+00:00 2026-05-29T05:46:46+00:00

This is a method I’m using to load saved game data from a file.

  • 0

This is a method I’m using to load saved game data from a file. I’m getting something called error15 at some point because of this. The only thing that came up on Google was something to do with http, but that can’t be it because I’m not doing anything like that. When the object prints the strings to the console, it completes the first line of saved data but doesn’t go on to read the others. I have a hunch it might have to do with my use of in.nextLine(); (is there something else I should be using instead?) If anyone can tell me what I’m doing wrong I will love you forever.

/**
 * Returns a 2-dimensional 15*15 array of saved world data from a file named by x and y coordinates
 */
public String[][] readChunkTerrain(int x, int y)
{
    String[][] data = new String[15][15]; //the array we will use to store the variables
    try {
        //initiate the scanner that will give us information about the file
        File chunk = new File( "World/" + x + "." + y + ".txt" );
        Scanner in = new Scanner(
                new BufferedReader(
                    new FileReader(chunk)));

        //go through the text file and save the strings for later
        for (int i=0; i<15; i++){
            for (int j=0; j<=15; j++){
                String next = in.next();
                data[i][j] = next;

                System.out.println(i + j + next); //temporary so I can see the output in console
                System.out.println();
            }
            in.nextLine();
        }

        in.close(); //close the scanner
    }
    //standard exception junk
    catch (Exception e)
    {System.err.println("Error" + e.getMessage());}

    return data; //send the array back to whoever requested it
}
  • 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-05-29T05:46:47+00:00Added an answer on May 29, 2026 at 5:46 am

    The error with the 15 you get (which you should have posted BTW, and would resulted in an immediate answer) is probably an ArrayIndexOutOfBoundsException since you try to access data[i][15] in your loop, which does not exists.

        for (int i=0; i<15; i++){
            for (int j=0; j<=15; j++){
    

    Your j loop should be adjusted to match the i loop as your data variable is initialized as new String[15][15]. So convert it to the following and all will work

            for (int j=0; j<15; j++){
    

    Note the < instead of <=

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

Sidebar

Related Questions

Using this method Assembly.Load(Byte(), Byte()) http://msdn.microsoft.com/en-us/library/twt16z2x.aspx It is possible to provide a byte representation
I'm using this method when file is loaded: $(<script/>, { class: test, src: 'http://www.externalSite.com/js/xxx.js'
Using this method on a 8x8 matrix: >> [junk,index] = unique(data,'first'); %# Capture the
With this method declaration (no overloads): void Method(double d) { // do something with
I have this method on a webpart: private IFilterData _filterData = null; [ConnectionConsumer(Filter Data
Should I be using this method of throwing errors: if (isset($this->dbfields[$var])) { return $this->dbfields[$var];
This method works great and generates only 1 query (utilizing .Includes() to eager load).
This method that uses method-level generics, that parses the values from a custom POJO,
This method doesn't work...but when I move away from returning a dictionary object and
what this method will return when the db is null for some reason? compile

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.