byte[] buffer = new byte[1024]; while (true) { int bytesRead = in.read(buffer); if (bytesRead == -1) break; out.write(buffer, 0, bytesRead); }
try { copy(System.in, System.out); } catch (IOException ex) { System.err.println(ex); }