I'm reading stdout of an Process using process.getInputStream()
. I wan to create an observable that will spew out Strings.
With StringObservable.from(process.getInputStream())
I'm getting Observable<byte[]>
. How to translate it in-flight into partial Strings ?
I have found https://github.com/ReactiveX/RxJava/wiki/String-Observables#decode but have no idea how to use it. Text is encoded in UTF-8.
您可以使用public static Observable<String> decode(Observable<byte[]> src, String charsetName)
,例如StringStringObservable.decode(StringObservable.from(process.getInputStream()), "UTF-8")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.