-5

I got a txt file and I'm using java.io.File in my code. I want to read the txt of each line, each line can have more than one word.

23
10
23
C34
Crew Quarters
1
1
4
false
Thomas Schmidt
  • 1,060
  • 2
  • 11
  • 31
cesar
  • 1
  • 2
  • 3
    What's your actual question? – JohannisK May 08 '15 at 13:12
  • 2
    Have you tried reading one of results from https://www.google.com/search?q=java+read+lines+from+file? – Pshemo May 08 '15 at 13:15
  • Also a similar question: ["Best way to read a text file"](http://stackoverflow.com/q/4716503/2991525) – fabian May 08 '15 at 13:20
  • this is how I use just with java.io.file cause Suppose that i can't add another reader, I know that exist other ways but it tells me that I have to use it with that io – cesar May 08 '15 at 13:30
  • *"Suppose that i can't add another reader, ..."* - Why can't you do that? Is this a real problem or a hypothetical question (or a quiz)? – Stephen C May 08 '15 at 13:44

1 Answers1

2

Use loop then read all lines.

  for (String line : Files.readAllLines(Paths.get("/path/to/file.txt"))) {
        // ...
    }
OPK
  • 3,870
  • 5
  • 30
  • 56