Witam, otoz mam problem z dodaniem fukncji pokazujacej mi procent rozpakowywania pliku .zip.
Uzywam kodu podanego nizej, jednak nie mam zupelnego pojecia w jaki sposob moge dodac by w JOptionPane zamiast ILOSC_PROCENT pokzywalo mi stan rozpakowywania pliku to znaczy 13%, 15%,16% itp.
Ktos ma jakis pomysl jak to zrobic ?
public class Read {
public static void main(String[] args) throws IOException {
JOptionPane.showMessageDialog(null,"Rozpakowywanie *ILOSC_PROCENT*!");
String filename = (System.getProperty("user.home"));
getZipFiles(filename);
}
public static void getZipFiles(String filename) {
try {
String destinationname = (System.getProperty("user.home"));
byte[] buf = new byte[1024];
ZipInputStream zipinputstream = null;
ZipEntry zipentry;
zipinputstream = new ZipInputStream(
new FileInputStream(filename));
zipentry = zipinputstream.getNextEntry();
while (zipentry != null) {
String entryName = destinationname + zipentry.getName();
entryName = entryName.replace('/', File.separatorChar);
entryName = entryName.replace('\\', File.separatorChar);
System.out.println("Wypakowano " + entryName);
int n;
FileOutputStream fileoutputstream;
File newFile = new File(entryName);
if (zipentry.isDirectory()) {
if (!newFile.mkdirs()) {
break;
}
zipentry = zipinputstream.getNextEntry();
continue;
}
fileoutputstream = new FileOutputStream(entryName);
while ((n = zipinputstream.read(buf, 0, 1024)) > -1) {
fileoutputstream.write(buf, 0, n);
}
fileoutputstream.close();
zipinputstream.closeEntry();
zipentry = zipinputstream.getNextEntry();
}
zipinputstream.close();
rozp_url2.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}