object を使用するとOutputSupplier
、最初の行の追加 ( CharStreams.write
) が正しく実行されます。しかし、CharStreams.write
もう一度呼び出すと、IOException
.
これはオブジェクトの正しい動作ですか? もしそうなら、どうすればString
インライン ストリームを閉じずにサプライヤー オブジェクトに a を追加できますか?
...
final Process process = Runtime.getRuntime().exec("su");
OutputSupplier<OutputStreamWriter> writerSupplier = CharStreams.newWriterSupplier(new OutputSupplier<OutputStream>() {
@Override
public OutputStream getOutput() throws IOException {
return process.getOutputStream();
}
}, Charsets.UTF_8);
// ok
CharStreams.write(someCommand, writerSupplier);
...
// IOException
CharStreams.write(otherCommand, writerSupplier);