1

Topic: Iterator implementation by data from URL

Let's assume that the following code loads a collection of homogeneous objects in JSON or XML: Parser parser = new Parser (new URL ("https://example.com/api/endpoint").openStream ()); For each object from a collection any logic which can occupy about one minute is fulfilled. Thus a parcer stream. The interface of all loading process and decoding turns around in java.util. Iterator, and the code of performance of logic, accordingly, will use methods hasNext () and next (). What happens, if the server without waited, while the data will be completely sent,  connection? Or better to say, URL:: openStream returns InputStream which data is completely read out in storage? Or the data on a network is transferred on time to proportionally calls InputStream:: read?

2

Re: Iterator implementation by data from URL

Hello, mbait, you wrote: M> Or better to say, URL:: openStream returns InputStream which data is completely read out in storage? Or the data on a network is transferred on time to proportionally calls InputStream:: read? The second, there generally generally the data can be more than storages. Accordingly all breaks.

3

Re: Iterator implementation by data from URL

Hello, mbait, you wrote: M> That happens, if the server without waited, while the data will be completely sent,  connection? By the next call inputStream.read he can throw out an exception. M> or better to say, URL:: openStream returns InputStream which data is completely read out in storage? Or the data on a network is transferred on time to proportionally calls InputStream:: read? And what to guess, climb , yes look. At me HttpURLConnection returns  class HttpURLConnection$HttpInputStream, which is a wrapper over KeepAliveStream, which is a wrapper over BufferedInputStream (with the size of the buffer in 8) which is a wrapper (I I "love" ) over, at last, SocketInputStream th. Actually 8 KB of the data in the buffer will lie (including HTTP headers and ), then throws an exception.