IterableStream (Azure SDK for Java Reference Documentation)

Code sample using Stream Code sample using Iterator Code sample using Stream and filter

This class provides utility to iterate over values using standard 'for-each' style loops, or to convert them into a Stream and operate in that fashion. All the values are preserved even if they are traversed multiple times.

Code sample using Stream

// process the stream myIterableStream.stream().forEach(resp -> { if (resp.getStatusCode() == HttpURLConnection.HTTP_OK) { System.out.printf("Response headers are %s. Url %s%n", resp.getDeserializedHeaders(), resp.getRequest().getUrl()); resp.getItems().forEach(value -> { System.out.printf("Response value is %d%n", value); }); } }); 

Code sample using Iterator

// Iterate over iterator for (PagedResponseBase<String, Integer> resp : myIterableStream) { if (resp.getStatusCode() == HttpURLConnection.HTTP_OK) { System.out.printf("Response headers are %s. Url %s%n", resp.getDeserializedHeaders(), resp.getRequest().getUrl()); resp.getItems().forEach(value -> { System.out.printf("Response value is %d%n", value); }); } } 

Code sample using Stream and filter

// process the stream myIterableStream.stream().filter(resp -> resp.getStatusCode() == HttpURLConnection.HTTP_OK) .limit(10) .forEach(resp -> { System.out.printf("Response headers are %s. Url %s%n", resp.getDeserializedHeaders(), resp.getRequest().getUrl()); resp.getItems().forEach(value -> { System.out.printf("Response value is %d%n", value); }); }); 

ncG1vNJzZmiZqqq%2Fpr%2FDpJuom6Njr627wWeaqKqVY8SqusOorqxmnprBcHDWnploopGrrnCt2a6pnmWTpL%2Bme5BnaWdoX5i8rnvAs6yrnV%2BYvLOxjq6roqRffsGmvsCbo56LpKeyormNoaumpA%3D%3D

 Share!