public static void downCRL(String crlurl, String filepath) { logger.info("开始下载更新CRL"); // 创建URL 对象 URL url = null; byte[] b = null; FileOutputStream fos = null; InputStream is = null; HttpURLConnection httpUrlConnection = null; try { url = new URL(crlurl); // 获取 httpUrl连接 httpUrlConnection = (HttpURLConnection) url.openConnection(); is = httpUrlConnection.getInputStream(); b = new byte[1024]; int j; fos = new FileOutputStream(new File(filepath)); while ((j = is.read(b)) != -1) { fos.write(b, 0, j); fos.flush(); } is.close(); fos.close(); httpUrlConnection.disconnect(); } catch (MalformedURLException e) { logger.info("下载CRL列表失败!"); e.printStackTrace(); } catch (IOException e) { logger.info("下载CRL列表失败!"); e.printStackTrace(); } }
时间: 2024-10-10 01:39:00