private String nextWithAltDelimiter(Scanner source, Pattern altDelimiter) { Pattern delimiter = source.delimiter(); try { source.useDelimiter(altDelimiter); return source.next(); } finally { source.useDelimiter(delimiter); } }
protected String nextDelimiter(Scanner source) { Pattern delimiter = source.delimiter(); try { source.useDelimiter(AFTER_DELIMITER); if (source.hasNext()) { return source.next(); } else { return null; } } finally { source.useDelimiter(delimiter); } }