1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| private void unrar(String filename)
{
listeFichiersTemp = new LinkedList();
File f = new File(filename);
Archive a = null;
try {
a = new Archive(f);
} catch (RarException e) {
// TODO Auto-generated catch block
e.printStackTrace();
JOptionPane.showMessageDialog(null, "Message d'erreur", "RAREXCEPTION 1", JOptionPane.ERROR_MESSAGE);
return;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
JOptionPane.showMessageDialog(null, "Message d'erreur", "IOEXCEPTION 1", JOptionPane.ERROR_MESSAGE);
return;
}
if(a != null){
a.getMainHeader().print();
FileHeader fh = a.nextFileHeader();
while(fh != null){
try {
//créer répertoire de sortie
String répertoireDeSortie = TempDirectory + f.getName()+"\\";
File rs = new File(répertoireDeSortie);
rs.mkdirs();
File out = new File(répertoireDeSortie + fh.getFileNameString().trim());
listeFichiersTemp.add(out.getAbsolutePath()); //listeFichiers.get(i));
//System.out.println(listeFichiers.get(0));//out.getAbsolutePath());
FileOutputStream os = new FileOutputStream(out);
a.extractFile(fh, os);
processFileList2();
chargeImages2();
os.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
JOptionPane.showMessageDialog(null, "Message d'erreur", "FILENOTFOUND", JOptionPane.ERROR_MESSAGE);
} catch (RarException e) {
// TODO Auto-generated catch block
e.printStackTrace();
JOptionPane.showMessageDialog(null, "Message d'erreur", "RAREXCEPTION 2", JOptionPane.ERROR_MESSAGE);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
JOptionPane.showMessageDialog(null, "Message d'erreur", "IOEXCEPTION 2", JOptionPane.ERROR_MESSAGE);
}
fh=a.nextFileHeader();
}
}
} |
Partager