int[] decodedIntsExpected = {3, 0, -4, 123, 12, 1000000, -123456};
String strExpected = "cat";
BencodeInputFactory f = new DefaultBencodeInputFactory();
try (InputStream s = new ByteArrayInputStream(bencodedInts.getBytes("US-ASCII"))) {
BencodeStreamReader r = f.createBencodeStreamReader(s);
int decodedIntIndex = 0;
while(r.hasNext()) {
r.next();
if (EventType.INT == r.getEventType()) {
long num = r.getInt();
assertEquals(decodedIntsExpected[decodedIntIndex++], num);
}
if (EventType.STRING == r.getEventType()) {
String str = r.getString();
assertEquals(strExpected, str);
}
}
}
}