I encounter some problem when using useDelimiter from the Scanner class.
Scanner sc = new Scanner(System.in).useDelimiter(\"-\"); while(sc.hasNext()) { S
You could use an alternative delimiter string useDelimiter( "-|\n" ); It works with a String argument as well as by reading from System.in. In case of System.in this requires you to press enter at the end of the line.
useDelimiter( "-|\n" );
System.in