Java tutorial
//package com.java2s; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; public class Main { public static final String ZIP_BUNDLE_NAME = "bundle.zip"; public static final void downloadBundle(InputStream is, String saveFilePath) throws IOException { checkDir(saveFilePath); File file = new File(saveFilePath, ZIP_BUNDLE_NAME); if (!file.exists()) { file.createNewFile(); } FileOutputStream outputStream = new FileOutputStream(file, false); byte[] buf = new byte[1024]; int len; while ((len = is.read(buf)) > 0) { outputStream.write(buf, 0, len); } outputStream.close(); is.close(); } public static void checkDir(String dirPath) { File dir = new File(dirPath); if (!dir.exists()) { dir.mkdirs(); } } }