Bonjour à tous ,

Voilà j'ai un soucis relativement étrange concernant la génération de fichiers ZIP avec java.util. En effet, dans tous les cas ma génération se passe sans aucun problème. Voici le code ci-dessous:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
		//These are the files to include in the ZIP file 
		String[] filenames = new String[]{"C:\\sysiclog.txt", "C:\\Montreal_Twilight_Panorama_2006.jpg"}; 
 
		// Create a buffer for reading the files 
		byte[] buf = new byte[1024]; 
 
		try { 
 
			// Create the ZIP file 
			String outFilename = "outfile.zip"; 
			ZipOutputStream out = new ZipOutputStream(new FileOutputStream(outFilename)); 
 
			// Compress the files 
			for (int i=0; i<filenames.length; i++) 
			{ 
				FileInputStream in = new FileInputStream(filenames[i]); 
 
				// Add ZIP entry to output stream. 
				out.putNextEntry(new ZipEntry(filenames[i])); 
 
				// Transfer bytes from the file to the ZIP file 
				int len; 
 
				while ((len = in.read(buf)) > 0) 
				{ 
					out.write(buf, 0, len); 
				}
				// Complete the entry 
				out.closeEntry(); 
				in.close(); 
			} // Complete the ZIP file 
 
			out.close(); 
		} 
		catch (IOException e) {
			System.out.println( e.toString());
		}
		catch (Exception e) {
			System.out.println( e.toString());
		}
	}
Le soucis survient à la décompression. Cette dernière marche très bien avec des outils de type Winzip, Winrar, 7zip etc... mais avec l'outil natif de Windows XP, j'ai l'erreur suivante:



L'API org.apache.commons.compress marche très bien dans tous les cas mais je suis limité à Java 1.3 pour le moment ce qui ne me permet pas de l'utiliser (1.4 minimum).

Avez-vous des solutions à cet étrange problème ?

Merci à vous.