Using Scanner to read words from text file

Java, Tip 20.11.2014 1 Comment

Often you need to read a file line by line. Alternatively sometimes you want to read text word by word (for example to count the occurrence of different words). The Scanner classes next() method can be used for this as shown in the following example. You can find an example of the use of the…

Read More

How do I read a text file line by line?

Java, Tip 20.11.2013 No Comments

The readLine() method of class reads the next line from a text file. When it reaches the end of the file it will return null.

Read More