この例外によって null のストリーム値を確認できますか:
(null != サプライヤー)
または、チェックが必要です:
(null != readerSupplier.getInput())
出力ストリームを flush() する必要がありますか? コメントを参照してください。
public void run() {
try {
final Process process = Runtime.getRuntime().exec("su");
InputSupplier<InputStreamReader> readerSupplier = CharStreams.newReaderSupplier(new InputSupplier<InputStream>() {
@Override
public InputStream getInput() throws IOException {
return process.getInputStream();
}
}, Charsets.UTF_8);
OutputSupplier<OutputStreamWriter> writerSupplier = CharStreams.newWriterSupplier(new OutputSupplier<OutputStream>() {
@Override
public OutputStream getOutput() throws IOException {
return process.getOutputStream();
}
}, Charsets.UTF_8);
// can I check the stream objects for null readerSupplier/writerSupplier?
// or need: readerSupplier.getInput()/writerSupplier.getOutput()?
if (null != readerSupplier && null != writerSupplier) {
...
CharStreams.write(someCommand, writerSupplier);
// should I flush() output stream? How better? Flushables.flush(writerSupplier) or Flushables.flush(writerSupplier.getOutput())
}