1.6 Customizing Client Setup Parameters

URLConnection introduces the following setup fields and corresponding methods.

field method

 




boolean doinput void setDoInput(boolean)

 




boolean dooutput void setDoOutput(boolean)

 




boolean connectedvoid connect()

opens a communications link, if a connection does not exist

<..request connection for input..>
 URL url = new URL( args[0] );
 URLConnection connection = url.openConnection();
 connection.setDoInput(true); // ??? works also without this line ???
 InputStream is = connection.getInputStream();
 InputStreamReader isr = new InputStreamReader(is);
 BufferedReader in = new BufferedReader(isr);
-_-_-
Caching



field method

 




long ifmodifiedsincesetIfModifiedSince

support fetching of only non-cached modified objects




boolean usecaches setUseCaches

control when caching is allowed

client interaction



field method

 




boolean allowuserinteractionsetAllowUserInteraction

control user interactions such as popping up an authentication dialog