Java does not have a Char Stream, so when working with String
s and constructing a Stream
of Character
s, an option is to get a [IntStream](<https://docs.oracle.com/javase/8/docs/api/java/util/stream/IntStream.html>)
of code points using String.codePoints()
method. So IntStream
can be obtained as below:
public IntStream stringToIntStream(String in) {
return in.codePoints();
}
It is a bit more involved to do the conversion other way around i.e. IntStreamToString. That can be done as follows:
public String intStreamToString(IntStream intStream) {
return intStream.collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append).toString();
}