• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to read speific lines in a text file  RSS feed

 
Willie Tsang
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If i were to read a text.txt file which is format like this:

string int int
string int int
string int int
string int int
string int int

how am i able to read, 3rd row 2nd int, and know exact value of it?
thanks in advance.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Willie Tsang wrote:
how am i able to read, 3rd row 2nd int, and know exact value of it?
thanks in advance.


By reading 3 lines, then splitting that line on spaces and taking the 3rd element, and then parsing that string as an int.
 
Willie Tsang
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do i split on spaces?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16059
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Class java.lang.String has a useful method for that. Look it up in the API documentation.
 
Willie Tsang
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks. i got it.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!