Runnable (final InputStream inputStream, final PrintStream outputStream) { return new Runnable() { @Override public void run() { try { try (BufferedReader inputReader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) { while (true) { String line = inputReader.readLine(); if (line == null) break; outputStream.println(line); } } } catch (UnsupportedEncodingException ignored) { } catch (IOException e) { e.printStackTrace(); } } }; }