Jun 24, 2017

Java provides a Scanner class that can be used as a text parser.

The Java class Scanner is used for text parsing.

Scanner implements the AutoCloseable interface so we can use it in try-with-resources block.

It accepts a regular expression as a delimiter and returns tokens separated by the delimiter.

try (Scanner scanner = new Scanner(new File(filename));) {
    while (scanner.hasNext()) {
    String word = scanner.next();

By setting the delimiter appropriately, various parsing tasks can be accomplished.

scanner.useDelimiter("put regular expression here");
Post a Comment

Featured Post

The price of ether, the cryptocurrency of the Ethereum network, has fallen below $500 for the first time this year.

Many new cryptocurrency offerings are built on top of the Ethereum platform. People creating a new token on the Ethereum blockchain need...