Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

help reading file

  Asked By: Danielle    Date: Dec 24    Category: Java    Views: 774

Can anyone tell me how rea a .txt file row after row?



2 Answers Found

Answer #1    Answered By: Ludo Ricci     Answered On: Dec 24

Here is one way of reading  a file  row after row:
String pathToFile = filename; //filename to read in
String recordHolder; //holds line of data
File in = new File(filename);
try {
BufferedReader InFile = new BufferedReader( new
FileReader(in) );

//get record from input file
while(( recordHolder = InFile.readLine() ) != null)
//put your code here
} catch(IOException ioe){//error code here }

Answer #2    Answered By: Luigi Fischer     Answered On: Dec 24

Use getLine function.........................

Didn't find what you were looking for? Find more on help reading file Or get search suggestion and latest updates.