₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,917 members, 8,424,183 topics. Date: Wednesday, 10 June 2026 at 07:46 PM

Toggle theme

Java Read From A File - Tech Jobs - Nairaland

Nairaland ForumScience/TechnologyProgrammingTech JobsJava Read From A File (741 Views)

1 Reply

Java Read From A File by 2legit2qwt(op): 3:45am On Dec 11, 2011
Hi guys,
I am working on this program that will read from a file and store each line in an array. However, I want each line stored in an array of an object which i created. I will really appreciate any help on this. I'm gonna paste the class I created which i want the array to be stored by line and also the text file I want to read into it.

Here's my vehicle class

public class Vehicle {
private String vin;
private String rentalType;
private String make;
private String model;
private int year;
private String color;
private double mileage;
private double rentalPrice;
private boolean rentalStatus = false;
public Vehicle(String aVin, String rentType, String amake, String amodel, int yr, String acolor,
double mile, double arentalPrice, boolean rentalS ){

vin= aVin;
rentalType= rentType;
make = amake;
model=amodel;
year=yr;
color= acolor;
mileage= mile;
rentalStatus= rentalS;
rentalPrice= arentalPrice;
}
public String getgetvin(){
return vin;
}
public String getrentalType(){
return rentalType;
}
public String getmake(){
return make;
}
public String getmodel(){
return model;
}
public int getyear(){
return year;
}
public String getColor(){
return color;
}
public double getmileage(){
return mileage;
}
public double getrentalPrice(){
return rentalPrice;
}
public void setrentalStatus(boolean rentalS){
if (rentalS = true)
rentalStatus= true;
}
public boolean getrentalStatus(){
return rentalStatus;
}
public double getVehiclePrice(){
return rentalPrice;
}
}

And the text file



Vehicle information
(vin, rental type, make, model, year, color, mileage, rental price, rental status)
1. 01X24, premium, Ford, Mustang, 2011, blue, 2356.03, 40.00, available
2. 01Y36, premum, Chevrolet, Camero, 2011, yellow, 785.94, 40.00, available
3. 01Z48, premium, Dodge, Challenger, 2011, black, 1382.28, 40.00, available
4. 11V48, standard, Honda, Accord, 2010, black, 7383.38, 30.00, available
5. 11V82, standard, Honda, Accord, 2011, silver, 2100.98, 30.00, available
6. 01M55, standard, Dodge, Charger, 2010, white, 3966.11, 30.00, available
7. 01B21, economy, Chevrolet, Aveo, 2010, red, 8291.56, 20.00, available
8. 01B36, economy, Chevrolet, Aveo, 2010, red, 9382.41, 20.00, available
9. 11B71, economy, Honda, Fit, 2011, blue, 4090.23, 20.00, available

The objective of the program is to ask the user to enter the vin and then based on the vin, the program will display the vehicle information while reducing the inventory of that car model by 1. I need help with reading each line into the array and identifying each line by the vin.


(hint on how to reduce the inventory will be greatly appreciated as well)
Thank you .
1 Reply

I Need An Application That Can Print Unique Pins On Separate A4 From Excel FileOlives File Registry And Tracking SystemFace Recognition File Manager Version 1.3 Is Out !234

Please I Need Someone That Can Make A Facebook Canvas PagePls Help Mi, I Nid The Syntax ASAPCompany Website Designer Needed