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?