Code example for URLConnection

Methods: connect, getContentLength

0
			 
			try{ 
			if(DBG )log("Creating connection");
			URL aurl = new URL(url);
			URLConnection conexion = aurl.openConnection();
			conexion.connect();
			if(DBG )log("Connection complete");
			 
			lengthOfFile = conexion.getContentLength();
			 
			} 
			catch(Exception e){
				lengthOfFile = -1;
				e.printStackTrace();
			} 
			 
			 
 
			if(DBG )log("Determining if files are the same");
            if((int)f.length() != lengthOfFile){
            	if(DBG )log("Files are not the same");