How to wrap a java.lang.Appendable into a java.io.Writer?

前端 未结 3 883
没有蜡笔的小新
没有蜡笔的小新 2020-12-21 08:37

UPDATE2: My own version of the adapter class, that only calls instanceof in the constructor and uses a (Java 1.5) delta in the flush() and cl

3条回答
  •  礼貌的吻别
    2020-12-21 09:14

    Google's Guava has a simple utility to do this: CharStreams.asWriter

    The implementation is not the fastest (see), if you want the best performance, you might want to look at spf4j Streams.asWriter

提交回复
热议问题