ramin_B
جمعه 29 اسفند 1393, 13:03 عصر
سلام
میخوام یه فایل رو zip کنم از کد زیر استفاده کردم اما خطا acces dinaied میدهد به نظر شما اشکال کجاست
public void getZipFiles(String zipFile, String destFolder) throws IOException {
BufferedOutputStream dest = null;
ZipInputStream zis = new ZipInputStream(new BufferedInputStream(new FileInputStream(zipFile)));
ZipEntry entry;
while (( entry = zis.getNextEntry() ) != null) {
System.out.println( "Extracting: " + entry.getName() );
int count;
byte data[] = new byte[1000];
if (entry.isDirectory()) {
new File( destFolder + "/" + entry.getName() ).mkdirs();
continue;
} else {
int di = entry.getName().lastIndexOf( '/' );
if (di != -1) {
new File( destFolder + "/" + entry.getName().substring( 0, di ) ).mkdirs();
}
}
FileOutputStream fos = new FileOutputStream( destFolder + "/" + entry.getName() );
dest = new BufferedOutputStream( fos );
while (( count = zis.read( data ) ) != -1) {
dest.write( data, 0, count );
}
dest.flush();
dest.close();
میخوام یه فایل رو zip کنم از کد زیر استفاده کردم اما خطا acces dinaied میدهد به نظر شما اشکال کجاست
public void getZipFiles(String zipFile, String destFolder) throws IOException {
BufferedOutputStream dest = null;
ZipInputStream zis = new ZipInputStream(new BufferedInputStream(new FileInputStream(zipFile)));
ZipEntry entry;
while (( entry = zis.getNextEntry() ) != null) {
System.out.println( "Extracting: " + entry.getName() );
int count;
byte data[] = new byte[1000];
if (entry.isDirectory()) {
new File( destFolder + "/" + entry.getName() ).mkdirs();
continue;
} else {
int di = entry.getName().lastIndexOf( '/' );
if (di != -1) {
new File( destFolder + "/" + entry.getName().substring( 0, di ) ).mkdirs();
}
}
FileOutputStream fos = new FileOutputStream( destFolder + "/" + entry.getName() );
dest = new BufferedOutputStream( fos );
while (( count = zis.read( data ) ) != -1) {
dest.write( data, 0, count );
}
dest.flush();
dest.close();