Here you can find the source of isFinite(Stream
public static <T> boolean isFinite(Stream<T> stream)
//package com.java2s; import java.util.stream.Stream; public class Main { public static <T> boolean isFinite(Stream<T> stream) { // Bascially Stream is an interface, so it is impossible to determine // if it is infinite or not. Any infinite stream provided by // java.util.stream package might be detected by inspecting their // implementation class, but it is still not a correct solution. throw new UnsupportedOperationException("Cannot be implemented"); }/*from w ww . jav a2s. co m*/ }