Is it safe for a method to return a Stream<T>?
Not only is it safe, it is recommended by the chief Java architect.
Especially if your data is I/O-based and thus not yet materialized in memory at the time myMethod
is called, it would be highly advisable to return a Stream instead of a List. The client may need to only consume a part of it or aggregate it into some data of fixed size. Thus you have the chance to go from O(n) memory requirement to O(1).
Note that if parallelization is also an interesting idea for your use case, you would be advised to use a custom spliterator whose splitting policy is adapted to the sequential nature of I/O data sources. In this case I can recommend a blog post of mine which presents such a spliterator.