public synchronized InputStream getInputStream ( ) throws IOException { if ( ! connected ) { connect ( ) ; } // Nothing to return if ( responseCode == HTTP_NOT_FOUND ) { throw new FileNotFoundException ( url . toString ( ) ) ; } int length ; if ( inputStream == null ) { return null ; } // "De-chunk" the output stream else if ( "chunked" . equalsIgnoreCase ( getHeaderField ( "Transfer-Encoding" ) ) ) { if ( ! ( inputStream instanceof ChunkedInputStream ) ) { inputStream = new ChunkedInputStream ( inputStream ) ; } } // Make sure we don't wait forever, if the content-length is known else if ( ( length = getHeaderFieldInt ( "Content-Length" , - 1 ) ) >= 0 ) { if ( ! ( inputStream instanceof FixedLengthInputStream ) ) { inputStream = new FixedLengthInputStream ( inputStream , length ) ; } } return inputStream ; }
Returns an input stream that reads from this open connection .