-3
String st = "FindCaptialWords";

Can we convert above string to character stream using StreamApi?

Nowhere Man
  • 18,291
  • 9
  • 17
  • 38
Mahesh Kshirsagar
  • 330
  • 1
  • 3
  • 10

1 Answers1

0

I just use

Stream<Character> foo = st.chars().mapToObj(c -> Character.valueOf((char) c));

though a stream of codepoints becomes much more useful than a stream of chars as soon as you need to deal with text outside of the BMP since a single char/Character can't hold those values, and so you're back to working with an IntStream as returned by st.codePoints().

Shawn
  • 38,372
  • 3
  • 13
  • 43