IntStream to String
suggest changeJava does not have a CharStream. When working with Strings, one option is to get an IntStream of Unicode code points from String.codePoints():
public IntStream stringToIntStream(String in) {
return in.codePoints();
}
The conversion the other way, from an IntStream of code points back to a String, can be done as follows:
public String intStreamToString(IntStream intStream) {
return intStream.collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append).toString();
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents