CharSequenceScanner extends AbstractCharStreamScannerImpl { public String substring(int start, int end) { return new String(this.buffer, this.initialOffset + start, end - start); } CharSequenceScanner(CharSequence charSequence);  CharSequenceScanner(String string);  CharSequenceScanner(char[] characters);  CharSequenceScanner(char[] characters, int offset, int length); char charAt(int index); int getLength(); String substring(int start, int end); String getReplaced(String substitute, int start, int end); @Deprecated void appendSubstring(StringBuffer appendable, int start, int end); void appendSubstring(StringBuilder appendable, int start, int end); int getCurrentIndex(); void setCurrentIndex(int index); @Override boolean hasNext(); @Override char next(); @Override char forceNext(); @Override char peek(); @Override char forcePeek(); String peek(int count); void stepBack(); @Override String readUntil(CharFilter filter, boolean acceptEot); @Override boolean expectStrict(String expected, boolean ignoreCase); @Override void require(String expected, boolean ignoreCase); @Override String readWhile(CharFilter filter, int max); String getOriginalString();  }
@Test public void testSubstring() { String string = "string"; CharSequenceScanner parser = new CharSequenceScanner(string); for (int i = 0; i <= string.length(); i++) { for (int j = i; j <= string.length(); j++) { assertThat(parser.substring(i, j)).isEqualTo(string.substring(i, j)); } } }