Thread: how do i...

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Posts
    0
    Rep Power
    0

    Question How do I?


    i need help programming in school with java
    i need to retrieve lines that were written to a file
    and show them in a pop up
    i have written the text file fine but now i am trying to read it line by line...

    any help will be appreciated
    Jon at Canby High
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Location
    Vancouver, WA
    Posts
    49
    Rep Power
    14
    Hi Jonathan (at school),

    You need to open the file and use the readLine method to read each line... put the following in a try..catch block

    Code:
    String filename = "somefile.txt";
    FileInputStream fin =  new FileInputStream(filename);
    DataInputStream myInput = new DataInputStream(fin);
    while ((thisLine = myInput.readLine()) != null) {  // while loop begins here
       // inside the loop, you can either out.println(), or append to a string, or do whatever you want with each line
    } // while
    --
    John Sturgeon <><
    johns@senareider.com
    http://www.senareider.com/technology.php
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Posts
    0
    Rep Power
    0

    Talking john


    to use a try catch go to http://www.trycatch.com u should find it useful
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Posts
    0
    Rep Power
    0

    Exclamation hey john sorry


    the actuall address is http://www.trycatch.edu not .com my bad
    good luck on your quest, any questions? email me
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Posts
    0
    Rep Power
    0

    Smile john i did some research


    ok heres what u do i have found out that trycatch.com doesnt exsist anymore so i will tell u how to write the program:

    1.) Get a Text book CD
    2.) go to chapter7
    3.) and read it all
    4.)then cut and paste from chapter 11 fig 11.4
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Posts
    0
    Rep Power
    0

    Unhappy more help from sammy


    you seem like a kid who is in a class he knows nothing about tell your teacher u need a lot of help
  12. #7
  13. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Location
    Rainy Oregon
    Posts
    1
    Rep Power
    0

    Thumbs down Teacher won't help, or we wouldn't be here


    Sammy,
    The teacher of Canby High's Computer Programming class wanted us to search on the Internet for web pages or forums that could help us. I think he got sick of everybody asking for a lot of help.
  14. #8
  15. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Posts
    0
    Rep Power
    0

    Question Oh your teacher said to find out on your own


    from my past experiences when a teacher says find out on your own it means he has no clue on how to do it? So i will help! Heres what u do since your cd's broken go to http://www.msn.com and search for a copy of the text book cd you can download. If you can't find one contact me. I should have more time this weekend to help you.

    [Edited by Sammy on 03-02-2001 at 11:42 AM]

IMN logo majestic logo threadwatch logo seochat tools logo