how to mock file stream in java code example Example: mock stream java when(mock.streamMethod()).thenAnswer(invocation -> Stream.of("A", "B"))