我有點新的Android和Java編程,可有人告訴我如何保存這些文件,我有以下代碼:如何保存文件到SD卡
InputStream is = new FileInputStream(location + "/zipSample.zip");
ZipInputStream zis = new ZipInputStream(new BufferedInputStream(is));
try {
ZipEntry ze;
while ((ze = zis.getNextEntry()) != null) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int count;
while ((count = zis.read(buffer)) != -1) {
baos.write(buffer, 0, count);
}
String filename = ze.getName();
byte[] bytes = baos.toByteArray();
// Do something with 'filename' and 'bytes' ...
// How do I save to sdcard?
}
} finally {
zis.close();
}
非常感謝您的幫助。
[中寫入一個文件到SD卡]的可能重複(http://stackoverflow.com/questions/2455102/writing-a-file-to-sdcard) – jww