Is it possible to convert stream of chars str.chars()
to stream with Strings, where each String contains 5 characters, for example?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
I don't think trying to combine elements from the characters is a good fit for Java streams without using some third party libraries.
If you want a stream of 5 character substrings I would split them like this:
Yes, it is possible if using a stateful lambda expression, but it is considered to be a bad practice.
One should be able to process the stream in serial or parallel. The order of the element processing would be different, but both should lead to the same result, which is possible only with stateless expressions.
You can simply split you string into five character sized strings using
If it has to be using streams, you may use, e.g.