-
Please Help!
If ne1 can help it would be very appreciated. Im running out of time.
Im trying to read records from a text file and put them in a vector but all im getting in the vector is nulls.
I didnt set the varibles to any length so i cant tell the do while loop when to stop.
Is dere any way to get around this?
Please Help!
public void openStream()
{
try
{
File inFile = new File(strBookLoc);
FileInputStream inFileStream = new FileInputStream(inFile);
InputStreamReader in = new InputStreamReader(inFileStream);
BufferedReader bufReader = new BufferedReader(in);
do
{
strTitle = bufReader.readLine();
strAuthor = bufReader.readLine();
strPrice = bufReader.readLine();
strStock = bufReader.readLine();
strDescription = bufReader.readLine();
if (strTitle != null)
{
intPrice = Integer.parseInt(strPrice);
intStock = Integer.parseInt(strStock);
}
i = i + 1;
Bookc bk = new Bookc(strTitle, strAuthor, intPrice, intStock, strDescription);
vtrBook.add(bk);
}while(strTitle != null);
bufReader.close();
}
catch (IOException e)
{
System.out.println("Error reading from file.");
System.out.println("Error message "+e.toString());
}
}
-
Its alright i fixed my problem.
Thanks neway
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks