473,378 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

how do i read from a text file into a new object which is stored in a array?

hi iam a java noob and iam trying to implement a method called "loadVehicleDetails" which reads from a text file using the BufferedReader command and creates a new Vehicle object from it and stores each of the new vehicles into an array.
This is what i have so far for the method
Expand|Select|Wrap|Line Numbers
  1.  
  2. public void loadVehicleDetails() throws IOException
  3.   {
  4.     BufferedReader inputVehicleFile; 
  5.  
  6.     String aManufacturer;
  7.     String aModel;
  8.     String aRegNo;
  9.     int aYear;
  10.     int aValue;
  11.     int aMileage;
  12.  
  13.     inputVehicleFile= Text.open ( "F:/fleetdetails.txt" ); 
  14.  
  15.     vehicleCount = 0; 
  16.     aManufacturer = ""; 
  17.     aModel = "";
  18.     aRegNo = "";
  19.     aYear = 0;
  20.     aValue = 0;
  21.     aMileage = 0;
  22.  
  23.     while ( aManufacturer.equals ("****") == false)
  24.     {
  25.         for (int i = 0; i < MAX_VEHICLES; i++) 
  26.        {
  27.          vehicleDetails [i] = new Vehicle (aManufacturer, aModel, aRegNo, aYear, aValue, aMileage  );
  28.          vehicleCount++;
  29.        }
  30.     }   
  31.     inputVehicleFile.close ();// close file
  32.   }// end of loadVehicleDetails
  33.  
iam not even sure if im going in the right direction.
The data from the text file is shown below
Expand|Select|Wrap|Line Numbers
  1. Volvo
  2. S40 1.6 S
  3. CC05ABC
  4. 2005
  5. 11987
  6. 9800
  7. Toyota
  8. Rav 4 2.0 D-4D XT3
  9. AB05RAV
  10. 2005
  11. 15000
  12. 1566
  13. ****
  14.  
any help is appericated
many thanks
May 13 '07 #1
0 975

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Sandi | last post by:
I have a simple problem: I have an Access database (images.mdb) that has 2 columns: one is the id of the picture (an integer) and one (column named picture) is a field of type OLE Object which...
19
by: ranjeet | last post by:
Hay Guys can you all suggest me the points on the below issue Problem : The thing is that I have the data some thing like this. 1486, 2168, 3751, 9074, 12134, 13944, 17983, 19173, 21190,...
3
by: Sandi | last post by:
I have a simple problem: I have an Access database (images.mdb) that has 2 columns: one is the id if the picture (an integer) and one (column named picture) is a field of type OLE Object which...
2
by: sani8888 | last post by:
Hi everybody I am a beginner with C++ programming. And I need some help. How can I start with this program *********** The program is using a text file of information as the source of the...
6
by: xdeath | last post by:
Hi guys, i've currently got an assignment, whereby, im supposed to create 2 classes, a Vehicle superclass, and a Taxi subclass. Vehicle class needs to have Reg Number, model, price, and Taxi is...
3
by: =?Utf-8?B?ZGF2aWQ=?= | last post by:
I try to follow Steve's paper to build a database, and store a small text file into SQL Server database and retrieve it later. Only difference between my table and Steve's table is that I use NTEXT...
5
by: john009 | last post by:
hmmmm...thanks to all that are willing to help i am using VB 6...theres more than one question i wish to ask please bare with me...i have to read in information from a file which the program...
13
by: rohit | last post by:
Hi All, I am new to C language.I want to read integers from a text file and want to do some operation in the main program.To be more specific I need to multiply each of these integers with another...
5
by: dm3281 | last post by:
Hello, I have a text report from a mainframe that I need to parse. The report has about a 2580 byte header that contains binary information (garbage for the most part); although there are a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.