Please Help!


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Please Help!

  1. #1
    Join Date
    Mar 2005
    Posts
    3

    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());
    }

    }

  2. #2
    Join Date
    Mar 2005
    Posts
    3
    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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center