Java Reference
In-Depth Information
Reader r = new InputStreamReader ( in );
int c ;
while (( c = r . read ()) != - 1 ) {
System . out . print (( char ) c );
}
System . out . println ();
}
} catch ( IOException ex ) {
System . err . println ( ex );
}
}
}
}
Here's the result. First, you see the default value: midnight, January 1, 1970, GMT, con‐
verted to Pacific Standard Time. Next, you see the new time, which you set to 24 hours
prior to the current time:
% java Last24 http://www.elharo.com
Original if modified since: Wed Dec 31 19:00:00 EST 1969
Will retrieve file if it's modified since Sat Jun 01 11:11:27 EDT 2013
Because this document hasn't changed in the last 24 hours, it is not reprinted.
protected boolean useCaches
Some clients, notably web browsers, can retrieve a document from a local cache, rather
than retrieving it from a server. Applets may have access to the browser's cache. Stand‐
alone applications can use the java.net.ResponseCache class. The useCaches variable
determines whether a cache will be used if it's available. The default value is true ,
meaning that the cache will be used; false means the cache won't be used.Because
useCaches is protected , programs access it using the getUseCaches() and
setUseCaches() methods:
public void setUseCaches ( boolean useCaches )
public boolean getUseCaches ()
This code fragment disables caching to ensure that the most recent version of the docu‐
ment is retrieved by setting useCaches to false :
try {
URL u = new URL ( "http://www.sourcebot.com/" );
URLConnection uc = u . openConnection ();
uc . setUseCaches ( false );
// read the document...
} catch ( IOException ex ) {
System . err . println ( ex );
}
Two methods define the initial value of the useCaches field, getDefaultUseCaches()
and setDefaultUseCaches() :
Search WWH ::




Custom Search