Код: Выделить всё
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
FileOutputStream fileStream = new FileOutputStream(new File("/tmp/somefile"));
MultiOutputStream outStream = new MultiOutputStream(byteStream, fileStream);
outStream.write("Hello world".getBytes());
Спасибо!
Подробнее здесь: https://stackoverflow.com/questions/798 ... ts-at-once