read from file in java | Sololearn: Learn to code for FREE!
0

read from file in java

read from text file I have a text file This file has 10 lines How can I read the fourth and seventh line? And twice third row??

20th Jan 2019, 2:34 PM
Gafoor Ezzati
Gafoor Ezzati - avatar
1 Answer
+ 3
https://www.sololearn.com/learn/Java/2187/ Java reads a file one char at once. When a linebreak occurs, java will register this as \n. We can add every char to a list until java detects \n using an if statement. Then we can add the string to a list. We can use index numbers to get to the third and seventh line https://code.sololearn.com/cAee2xOyPB3F/?ref=app
20th Jan 2019, 4:12 PM
CodeMStr
CodeMStr - avatar