mardi 8 avril 2014

Java - Regex appliquant au-dessus d'un ruisseau pour extraire une chaîne - Stack Overflow


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?




These previous answers show a few options:



  1. Performing regex on a stream

  2. Applying a regular expression to a Java I/O Stream


I think that Scanner.findWithinHorizon mentioned by the first answer (above) may be an interesting option.



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?



These previous answers show a few options:



  1. Performing regex on a stream

  2. Applying a regular expression to a Java I/O Stream


I think that Scanner.findWithinHorizon mentioned by the first answer (above) may be an interesting option.


0 commentaires:

Enregistrer un commentaire