문제

Is there a clean and simple way to convert an instance of java.io.PrintWriter into a java.io.PrintStream?

도움이 되었습니까?

해결책

First obtain an OutputStream from the Writer. See this question

Then pass it as argument to the PrintStream constructor:

OutputStream os = new WriterOutputStream(writer);
PrintStream ps = new PrintStream(os);

Update: commons-io 2.0 has WriterOutputStream, so use it.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top