Skip to content Skip to sidebar Skip to footer

How To Get A Random Line From Text File In Android Using Android Studio 2.1.3?

I have a text file with 500 lines. I placed this text file in app/src/main/assets folder with the name 'words.txt'. In this file each line is separated with line break. Now i need

Solution 1:

Now this code works but always gives the first line. The random number is generated but the lnr (LineNumberReader) reads first line always. Why?

See this LineNumberReader

Note however, that setLineNumber(int) does not actually change the current position in the stream; it only changes the value that will be returned by getLineNumber().

So that's why it reading first line always.

Post a Comment for "How To Get A Random Line From Text File In Android Using Android Studio 2.1.3?"