Helpful Information
 
 
Category: Java Help
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

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



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

to use a try catch go to http://www.trycatch.com u should find it useful

the actuall address is http://www.trycatch.edu not .com my bad
good luck on your quest, any questions? email me

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

you seem like a kid who is in a class he knows nothing about tell your teacher u need a lot of help

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.

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]










privacy (GDPR)