Engine/ReadWithScanner.java
/** 
   Overridable method for processing lines in different ways.
    
   <P>This simple default implementation expects simple name-value pairs, separated by an 
   '=' sign. Examples of valid input: 
   <tt>height = 167cm</tt>
   <tt>mass =  65kg</tt>
   <tt>disposition =  "grumpy"</tt>
   <tt>this is the name = this is the value</tt>
  */
Overridable method for processing lines in different ways.
This simple default implementation expects simple name-value pairs, separated by an
'=' sign. Examples of valid input:
height = 167cm
mass =  65kg
disposition =  "grumpy"
this is the name = this is the value
Overridable method for processing lines in different ways . This simple default implementation expects simple name - value pairs separated by an ' = ' sign . Examples of valid input : height = 167cm mass = 65kg disposition = " grumpy " this is the name = this is the value
protected void processLine(String line){
    try(Scanner scanner = new Scanner(line)){
      scanner.useDelimiter("=");
      if (scanner.hasNext()){
        String name = scanner.next();
        String value = scanner.next();
        log("Name is : " + quote(name.trim()) + ", and Value is : " + quote(value.trim()));
      }
      else {
        log("Empty or invalid line. Unable to process.");
      }
    }
  }
protected void processLine ( String line ) { try ( Scanner scanner = new Scanner ( line ) ) { scanner . useDelimiter ( "=" ) ; if ( scanner . hasNext ( ) ) { String name = scanner . next ( ) ; String value = scanner . next ( ) ; log ( "Name is : " + quote ( name . trim ( ) ) + ", and Value is : " + quote ( value . trim ( ) ) ) ; } else { log ( "Empty or invalid line. Unable to process." ) ; } } }
Overridable method for processing lines in different ways.
Overridable method for processing lines in different ways .
//use a second Scanner to parse the content of each line  //assumes the line has a certain structure