Q:

Reading text file which has forward-given line terminator

In Java, I'm being given the text file location and line terminator, and I am supposed to read it line by line. 
Is there any way to override readLine() function, so that it reads lines from text file like readLineModified(char lineTerminator).

i.e. If there is a file with content "Foo foo $ bar bar $ foobar jonathan" it should be separated into lines  "Foo foo", "bar bar","foobar jonathan"?
 Code should not be using any "exotic" modules.

A:

You can use  java.util.Scanner like so:
   Scanner scanner = new Scanner(new File(fileName));
   scanner.useDelimiter("$");
   while (scanner.hasNext()) {
    System.out.println(scanner.next());
   }
   scanner.close();

