-3
String st = "FindCaptialWords";

Can we convert above string to character stream using StreamApi?

Nowhere Man
  • 19,170
  • 9
  • 17
  • 42
Mahesh Kshirsagar
  • 390
  • 1
  • 3
  • 12

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
  • 47,241
  • 3
  • 26
  • 60