是否有一种简单安全的方法将PrintWriter转换为Print

是否有一种简单安全的方法将PrintWriter转换为Print

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 questionThen 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. 这篇关于是否有一种简单安全的方法将PrintWriter转换为PrintStream?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-01 13:58