Hi, I have a class object that's like a database cursor, it has a next() method that reads the next table row.
class MyClass
Row next() throws DatabaseException {
...
}
I want to convert this to a stream since this also behaves like a lazy operation. I tried using Supplier which is accepted by Stream.generate(). Supplier have a method get() which has to be overridden for custom implementations.
Stream<Row> stream = Stream.generate(new Supplier<Row>(){
@Override
public Row get() {
// custom implementation
...
}
});
The only problem using this is that MyClass.next() throws an exception while Supplier.get() doesnt allow exceptions. Is there any other way to create a custom stream for such class?
