• Post Reply Bookmark Topic Watch Topic
  • New Topic

Facing problem in IO stream operation

 
shreyans ricky
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to read a file using FileReader. save it in BufferedReader and print it in a new file using PrintWriter. But the condition is that i need to print only 8 lines from a file of 200 lines.
How to print nextLine from BufferedReder ???
 
Ravin Psinh
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in reading loop what you were doing is reading the file until the buffereReader.nextLine() exists rather than doing this you should just loop for about 8 iteration and then in these loop read from bufferedReader.

by this you will be able to read 8 lines.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!