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

  • Home
  • SEARCH
  • 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 8857241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:32:36+00:00 2026-06-14T14:32:36+00:00

I have text .dat file and I load this file from my main class

  • 0

I have text .dat file and I load this file from my main class and read in my DataReader class. but I get errors that i have to change my modifier to static. I can’t do that because it is required to be non-static.

I am stuck here and not sue if my problem is here or somewhere else. will you check my codes and let me know if it is okay or not?
next line also does not store in vehicle and shows null!!

this code gets the error:

if(DataReader.loadData(args[0])) {   // i get errors here

and ask me to change this to: public static boolean loadData(String VehicleData) { /// but this code has to be non-static... ( required by my professor)

Main class:

public class Project3 {

private static Vehicle[] vehicles;
static int x;

public static void main(String[] args) {
    // Display program information


    DataReader reader = new DataReader(); // The reader is used to read data from a file


    // Load data from the file
    **if(DataReader.loadData(args[0]))** {   // i get errors here

        vehicles= reader.getVehicleData(); // this line also shows null

        // Display how many shapes were read from the file
        System.out.println("Successfully loaded " + vehicles[0].getCount() + 
                           " vehicles from the selected data file!");
        displayMenu();
    }
}

DataReader Class:

ublic boolean loadData(String VehicleData) {
    boolean validData = false;
    String line;

try{
// Open the file
    BufferedReader reader = new BufferedReader(new FileReader("VehicleData.dat"));
//Read File Line by line


        while((line=reader.readLine()) !=null) {
            addVehicle(line.split(","));
        }
        reader.close();
        vehicles = Array.resizeArray(vehicles, vehicleCount);
        validData = true;
    }   
  • 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-14T14:32:37+00:00Added an answer on June 14, 2026 at 2:32 pm

    You’ve create an instance of the reader but then chosen not to use it…

    DataReader reader = new DataReader(); // The reader is used to read data from a file
    if(DataReader.loadData(args[0]))
    

    You should just use the instance you have available

    DataReader reader = new DataReader(); // The reader is used to read data from a file
    if(reader.loadData(args[0]))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a VB script that reads the 11th line from a text file.
I have an html table that is populated from a text file, formatted and
I have text I am displaying in SIlverlight that is coming from a CMS
I have text file with some stuff that i would like to put into
I have text stored in SQL as HTML. I'm not guaranteed that this data
i have text like this div bla-bla end div i need to get only
I have a text file words.txt that contains english words. Let's assume it contains
I have a simple code that looks up a text file, reads the line
I have a text file containing the output of a recursive directory listing that
I have a text file that contains 113 line and 10 columns. Every line

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.