Code example for NetworkErrorException

0
			 
			/* 
			 * 检查网络是否可用 
			 */ 
			if (!NetworkUtils.isNetworkAvailable(context)) {
				throw new NetworkErrorException("网络不可用,请检查网络!");
			} 
			 
			/* 
			 * 检测文件长度 
			 */ 
			client = AndroidHttpClient.newInstance("DownloadTask");
			httpGet = new HttpGet(url);
			response = client.execute(httpGet);
			totalSize = response.getEntity().getContentLength();
 
			item.setTotalSize(totalSize);
			item.setDownloadSize(downloadSize + previousFileSize);
 
			if (file.exists() && totalSize == file.length()) {
				throw new FileAlreadyExistException("文件已经存在!");