从URL下载文件并解压缩
/*from NowJava.com - 时代Java*/ import java.io.*; import java.net.URL; import java.nio.file.Files; import java.nio.file.Paths; import java.nio.file.StandardCopyOption; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; public class Main{ public static void downloadFileInto(CharSequence stringURL, File directory) { try { URL url = new URL(stringURL.toString()); unzipIntoDirectory(url.openStream(), directory); } catch (IOException e) { e.printStackTrace(); } }/**时 代 Java 公 众 号 - nowjava.com**/ public static void unzipIntoDirectory(File file, File directory) { try { unzipIntoDirectory(new FileInputStream(file), directory); } catch (FileNotFoundException e) { e.printStackTrace(); } } public static void unzipIntoDirectory(InputStream inputStream, File directory) { if (directory.isFile()) return; directory.mkdirs(); try { inputStream = new BufferedInputStream(inputStream); inputStream = new ZipInputStream(inputStream); for (ZipEntry entry = null; (entry = ((ZipInputStream) inputStream) .getNextEntry()) != null;) { StringBuilder pathBuilder = new StringBuilder( directory.getPath()).append('/').append( entry.getName()); File file = new File(pathBuilder.toString());