public class

KeepAliveStream

extends MeteredStream
implements Hurryable
java.lang.Object
   ↳ java.io.InputStream
     ↳ java.io.FilterInputStream
       ↳ sun.net.www.MeteredStream
         ↳ sun.net.www.http.KeepAliveStream

Class Overview

A stream that has the property of being able to be kept alive for multiple downloads from the same server.

Summary

Fields
protected boolean queuedForCleanup
[Expand]
Inherited Fields
From class sun.net.www.MeteredStream
From class java.io.FilterInputStream
Public Constructors
KeepAliveStream(InputStream is, ProgressSource pi, int expected, HttpClient hc)
Constructor
Public Methods
void close()
Attempt to cache this connection
synchronized boolean hurry()
void mark(int limit)
Marks the current position in this input stream.
boolean markSupported()
Tests if this input stream supports the mark and reset methods.
void reset()
Repositions this stream to the position at the time the mark method was last called on this input stream.
Protected Methods
int remainingToRead()
void setClosed()
[Expand]
Inherited Methods
From class sun.net.www.MeteredStream
From class java.io.FilterInputStream
From class java.io.InputStream
From class java.lang.Object
From interface java.io.Closeable
From interface sun.net.www.http.Hurryable

Fields

protected boolean queuedForCleanup

Public Constructors

public KeepAliveStream (InputStream is, ProgressSource pi, int expected, HttpClient hc)

Constructor

Public Methods

public void close ()

Attempt to cache this connection

Throws
IOException

public synchronized boolean hurry ()

public void mark (int limit)

Marks the current position in this input stream. A subsequent call to the reset method repositions this stream at the last marked position so that subsequent reads re-read the same bytes.

The readlimit argument tells this input stream to allow that many bytes to be read before the mark position gets invalidated.

This method simply performs in.mark(readlimit).

Parameters
limit the maximum limit of bytes that can be read before the mark position becomes invalid.

public boolean markSupported ()

Tests if this input stream supports the mark and reset methods. This method simply performs in.markSupported().

Returns
  • true if this stream type supports the mark and reset method; false otherwise.

public void reset ()

Repositions this stream to the position at the time the mark method was last called on this input stream.

This method simply performs in.reset().

Stream marks are intended to be used in situations where you need to read ahead a little to see what's in the stream. Often this is most easily done by invoking some general parser. If the stream is of the type handled by the parse, it just chugs along happily. If the stream is not of that type, the parser should toss an exception when it fails. If this happens within readlimit bytes, it allows the outer code to reset the stream and try another parser.

Throws
IOException

Protected Methods

protected int remainingToRead ()

protected void setClosed ()