Reputation: 6961
We are using a REST API call that returns a string of a very large size. We are performing
httpget.getResponseBodyAsString();
to get the string returned by the REST call. Then we apply regex over this string to extract the substring that we require. When the string returned by the REST call is huge, we are facing Out Of Memory issues with the JVM.
We can also get the data from the REST call as a stream using
httpget.getResponseBodyAsString();
But is it possible to apply regex over the stream and extract the string that we require?
Upvotes: 0
Views: 409
Reputation: 8587
These previous answers show a few options:
I think that Scanner.findWithinHorizon mentioned by the first answer (above) may be an interesting option.
Upvotes: 2