### Question:
SegmentInputStream extends InputStream { @Override public int available() throws IOException { if (rpos < src.length() && src.charAt(rpos) != '.') { return 1; } else { return 0; } } SegmentInputStream(String src, int start); @Override int read(); @Override int available(); @Override boolean markSupported(); @Override synchronized void reset();  }### Answer:
@Test public void testSegmentEndMinusOne() throws IOException { String src = "hello world"; SegmentInputStream s = newSegmentInputStream(src, src.length() - 1); assertEquals(1, s.available()); String text = IOUtils.toString(s, StandardCharsets.UTF_8.name()); assertEquals("d", text); }