UnZip sınıfım, dosyanın tamamını açmıyor. Bu sınıf başka bir etkinlikten çağrılır. Zip dosyam, telefonun dahili belleğinin ana dizinine kaydedilir. Zip dosyasının klasörleri ve bazı videoları var. Bu unzip'in nesi var? Zip'lerden sıkıştırmayı açmak ve unzip ile aynı dosyayı nasıl ve nasıl okurum?Sıfırlanıyorsa hata oluştu
Yardımlarınız için teşekkürler!
public class Unzip {
private static final String INPUT_ZIP_FILE = "sdcard/downloaded_issue.zip";
private static final String OUTPUT_FOLDER = "sdcard/Atlantis/";
public static void main()
{
Unzip unZip = new Unzip();
unZip.unZipIt(INPUT_ZIP_FILE, OUTPUT_FOLDER);
}
/**
* Unzip it
* @param zipFile input zip file
* @param outputFolder zip file output folder
*/
public void unZipIt(String zipFile, String outputFolder){
byte[] buffer = new byte[1024];
try{
//create output directory is not exists
File folder = new File(OUTPUT_FOLDER);
if(!folder.exists()){
folder.mkdir();
}
//get the zip file content
ZipInputStream zis =
new ZipInputStream(new FileInputStream(zipFile));
//get the zipped file list entry
ZipEntry ze = zis.getNextEntry();
while(ze!=null){
String fileName = ze.getName();
File newFile = new File(outputFolder + File.separator + fileName);
System.out.println("file unzip : "+ newFile.getAbsoluteFile());
//create all non exists folders
//else you will hit FileNotFoundException for compressed folder
new File(newFile.getParent()).mkdirs();
FileOutputStream fos = new FileOutputStream(newFile);
int len;
while ((len = zis.read(buffer)) > 0) {
fos.write(buffer, 0, len);
}
fos.close();
if (ze.isDirectory()) {
ze = zis.getNextEntry();
}
}
zis.closeEntry();
zis.close();
System.out.println("Done");
}catch(IOException ex){
ex.printStackTrace();
}
}
}
? İlk bakışta Java ya da C# gibi görünüyor. – Nyerguds
Java. ve ben Android Studio ile programlama yapıyorum – Weblu
Bunu etiketleyin, sonra. Programlama dili dahil ise daha hızlı yanıt alırsınız; insanlar bunu filtrelemeye eğilimlidir. – Nyerguds