@Test void testOnDataRead() { final String data = "A"; List<String> receivedData = new ArrayList<>(); Consumer c = new Consumer(receivedData); InputStream stream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8)); StreamReader reader = new StreamReader(stream); reader.setOnInputRead(c::stringRecieved); reader.start(); try { reader.join(); } catch (InterruptedException e) { e.printStackTrace(); } assertEquals(receivedData.get(0), data); assertEquals(receivedData.get(1), String.valueOf((char) -1)); }
void setOnInputRead(Consumer<String> consumer) { this.onInputRead = consumer; }
StreamReader extends Thread { void setOnInputRead(Consumer<String> consumer) { this.onInputRead = consumer; } }
StreamReader extends Thread { void setOnInputRead(Consumer<String> consumer) { this.onInputRead = consumer; } StreamReader(InputStream inputStream); }
StreamReader extends Thread { void setOnInputRead(Consumer<String> consumer) { this.onInputRead = consumer; } StreamReader(InputStream inputStream); @Override void run(); }
StreamReader extends Thread { void setOnInputRead(Consumer<String> consumer) { this.onInputRead = consumer; } StreamReader(InputStream inputStream); @Override void run();  }