清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
URL url = new URL(Config.local + "/excel/" + name); HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection(); // 设置请求信息 httpConnection.setRequestProperty("GET", "/down.zip HTTP/1.1"); // 设置接受信息 httpConnection.setRequestProperty("Accept", "image/gif,image/x-xbitmap,application/msword"); // 设置连接信息 httpConnection.setRequestProperty("Connection", "Keep-Alive"); // 获得输入流 InputStream input = httpConnection.getInputStream(); // 创建随机文件 flist.add(new File(name)); RandomAccessFile oSavedFile = new RandomAccessFile(name, "rw"); byte[] b = new byte[1024]; int nRead; // 从输入流中读入字节流,然后写到文件中 while ((nRead = input.read(b, 0, 1024)) > 0) { oSavedFile.write(b, 0, nRead); } input.close(); oSavedFile.close(); httpConnection.disconnect();