3
3
import java .io .Closeable ;
4
4
import java .io .File ;
5
5
import java .io .IOException ;
6
+ import java .nio .charset .Charset ;
6
7
import java .util .Enumeration ;
7
8
import java .util .Iterator ;
8
9
9
10
import org .apache .commons .compress .archivers .zip .ZipArchiveEntry ;
10
11
import org .apache .commons .compress .archivers .zip .ZipFile ;
11
12
import org .codehaus .plexus .components .io .resources .AbstractPlexusIoArchiveResourceCollection ;
13
+ import org .codehaus .plexus .components .io .resources .EncodingSupported ;
12
14
import org .codehaus .plexus .components .io .resources .PlexusIoResource ;
13
15
14
16
public class PlexusIoZipFileResourceCollection
15
- extends AbstractPlexusIoArchiveResourceCollection
17
+ extends AbstractPlexusIoArchiveResourceCollection implements EncodingSupported
16
18
{
17
19
18
20
/**
19
21
* The zip file resource collections role hint.
20
22
*/
21
23
public static final String ROLE_HINT = "zip" ;
22
24
25
+ private Charset charset = Charset .forName ( "UTF-8" );
26
+
23
27
protected Iterator <PlexusIoResource > getEntries ()
24
28
throws IOException
25
29
{
@@ -28,7 +32,7 @@ protected Iterator<PlexusIoResource> getEntries()
28
32
{
29
33
throw new IOException ( "The tar archive file has not been set." );
30
34
}
31
- final ZipFile zipFile = new ZipFile ( f );
35
+ final ZipFile zipFile = new ZipFile ( f , charset . name () );
32
36
return new CloseableIterator ( zipFile );
33
37
}
34
38
@@ -68,5 +72,8 @@ public void close()
68
72
}
69
73
}
70
74
71
- ;
75
+ public void setEncoding ( Charset charset )
76
+ {
77
+ this .charset = charset ;
78
+ }
72
79
}
0 commit comments