Win a copy of Kotlin in Action this week in the Kotlin forum!
    Bookmark Topic Watch Topic
  • New Topic

How to read a file to an index?  RSS feed

 
Tracy Villa
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Report post to moderator
Is there any way to read a specific line in Java?

Without using arrays or BufferedReader
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Report post to moderator
I take it this is related to your other topic where you had been suggested using ArrayList. Care to share why you do not prefer that approach?

Coming back to your current question, check out http://docs.oracle.com/javase/tutorial/essential/io/rafs.html
 
Tracy Villa
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Report post to moderator
I'm trying not to use ArrayList because my teacher has not taught us that yet, so I think she is expecting a code that does not use it
 
Tracy Villa
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Report post to moderator
Oops, I accidentally marked the topic as resolved...even though it is not yet
 
Campbell Ritchie
Marshal
Posts: 55681
161
  • Mark post as helpful
  • send pies
  • Report post to moderator
You would have to iterate your file line by line until you got to the line you were looking for. Using a List is much more efficient.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Report post to moderator
There has been quite a lot of discussion in another related topic http://www.coderanch.com/t/597528/java/java/Random-Method-random-numbers-represent
I will close this one to avoid confusion and duplication
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!