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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T08:49:40+00:00 2026-05-21T08:49:40+00:00

If you want more info on the error, the full source can be downloaded

  • 0

If you want more info on the error, the full source can be downloaded here

Hey, I’m reading an ini file using java.util.Properties; and I’ve run into a strange issue. When I try to load a specific file, the thing spits out this strange exception that I’ve been trying for about a day to eliminate.

java.io.IOException: Read error
    at java.io.FileInputStream.readBytes(Native Method)
    at java.io.FileInputStream.read(Unknown Source)
    at java.util.Properties$LineReader.readLine(Unknown Source)
    at java.util.Properties.load0(Unknown Source)
    at java.util.Properties.load(Unknown Source)
    at IniReader.load(IniReader.java:20)
    at plane.<init>(plane.java:22)
    at renderingArea.<init>(flight_optimizer.java:93)
    at flight_optimizer_GUI.<init>(flight_optimizer.java:159)
    at flight_optimizer.main(flight_optimizer.java:46)

I had previously been reading this file just fine with no problems, I then changed a bit of how I was calling and had to add an extra line at the bottom. If I remove that line, the problem does not occour.

the txt file is:

x=0
y=0
max_velocity=.1
passengers=100
num_planes=1

If I remove the num_planes=1 line, the file gets read fine.

Relevant code:

import java.util.Enumeration;

public class IniReader {

    //global vars

    public IniReader(){
        // initializeing stuffs
    }

    public void load(InputStream inStream) throws IOException {
        this.inStream = inStream;
        this.properties.load(this.inStream);
        this.keys = this.properties.propertyNames();
        inStream.close();
    }
}

class renderingArea extends JPanel {

    //Global vars
    private IniReader ini;

    public renderingArea(){
        super();
        // Initializing some things 
        files = new fileManager();
        ini = new IniReader();

        FileInputStream planeStream;
        FileInputStream cityStream;
        try {
            planeStream = files.getIni("plane.ini");
            ini.load(planeStream);

            //extraneous code

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e1) {
            e1.printStackTrace();
        } catch (NumberFormatException e1) {
            e1.printStackTrace();
        }   
    }

    //moar extraneous code

}
  • 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-21T08:49:41+00:00Added an answer on May 21, 2026 at 8:49 am

    That is why:

    Your code (flight_optimizer.java, line 82 and further):

    FileInputStream planeStream;
    ...
    planeStream = files.getIni("plane.ini");
    ini.load(planeStream);
    ...
    for( int i=0; i<planes.length; i++ ){
        planes[i] = new plane(planeStream);
    }
    

    Both the second line and every cycle iteration leads us here (IniReader.java, line 17):

    public void load(InputStream inStream) throws IOException {
        this.inStream = inStream;
        this.properties.load(this.inStream);
        this.keys = this.properties.propertyNames();
        inStream.close();
    }
    

    You are trying to use the same InputStream multiple times, moreover, you are trying to use it after it already was closed. You will need to recreate the stream, or, preferably, read configuration once and use it multiple times.

    As a side note, the recommended way to use the streams in Java is the following:

    InputStream is = ...;
    try {
       // Reading from the stream
    } finally {
       is.close();
    }
    

    This will make sure that the system resources associated with the stream will always be released.

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

Sidebar

Related Questions

I'm trying to style a select option list using CSS. I want more padding
I seem to be missing something obvious here, why would I want more than
I want to send more than one image file from client to server for
Say I have a router helper that I want more info on, like blogs_path,
I want to create a signature for a file using OpenSSL. I believe that
I want to pass more than one variable to other web pages. I try
I want to add more functionality to a project I have that makes use
I want to understand more about the system and DB architecture of MongoDB. I
I want to create more or less portable (stand-alone, no install, WinXP to Win7)
I want to append more text behind UILabel in iOS. In other languages, we

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.