I find it a bit strange that the Java API does not provide a method to convert a String
to a Stream<Character>
, but this is how you can do it:
Stream<Character> stream = string.chars().mapToObj(i -> (char)i); // or: Stream<Character> stream = IntStream.range(0, string.length()) .mapToObj(string::charAt);