Can we create a Java stream with an infinite source of data (e.g. Health signals)?
Asked
Active
Viewed 137 times
-2
-
In what format do you receive the 'input' Health signal ? – azro Aug 07 '21 at 08:46
1 Answers
2
Yes.
Of course, limiting the size would cause the stream to be finite.
With, for example, Stream.generate(() -> "tick")
you have an infinite stream.
However, the actual implementation heavily depends on the shape of the source. If, for instance, for heart beats, I expect the stream coming from some external device, so then you'll need to setup the transmission as well.

MC Emperor
- 22,334
- 15
- 80
- 130