author | shade |
Fri, 11 May 2018 17:37:14 +0200 | |
changeset 50084 | 44b64fc0baa3 |
parent 47216 | 71c04702a3d5 |
child 53043 | fd2e8f941ded |
permissions | -rw-r--r-- |
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
1 |
/* |
43193
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
2 |
* Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved. |
23925
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
4 |
* |
23925
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
10 |
* |
23925
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
15 |
* accompanied this code). |
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
16 |
* |
23925
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
20 |
* |
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
23 |
* questions. |
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
24 |
*/ |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
25 |
|
23925
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
26 |
package jdk.nio.zipfs; |
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
27 |
|
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
28 |
import java.nio.ByteBuffer; |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
29 |
import java.nio.CharBuffer; |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
30 |
import java.nio.charset.Charset; |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
31 |
import java.nio.charset.CharsetDecoder; |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
32 |
import java.nio.charset.CharsetEncoder; |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
33 |
import java.nio.charset.CoderResult; |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
34 |
import java.nio.charset.CodingErrorAction; |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
35 |
import java.util.Arrays; |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
36 |
|
43193
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
37 |
import static java.nio.charset.StandardCharsets.UTF_8; |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
38 |
import static java.nio.charset.StandardCharsets.ISO_8859_1; |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
39 |
|
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
40 |
/** |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
41 |
* Utility class for zipfile name and comment decoding and encoding |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
42 |
* |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
43 |
* @author Xueming Shen |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
44 |
*/ |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
45 |
|
43193
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
46 |
class ZipCoder { |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
47 |
|
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
48 |
static class UTF8 extends ZipCoder { |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
49 |
UTF8() { |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
50 |
super(UTF_8); |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
51 |
} |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
52 |
|
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
53 |
@Override |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
54 |
byte[] getBytes(String s) { // fast pass for ascii |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
55 |
for (int i = 0; i < s.length(); i++) { |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
56 |
if (s.charAt(i) > 0x7f) return super.getBytes(s); |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
57 |
} |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
58 |
return s.getBytes(ISO_8859_1); |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
59 |
} |
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
60 |
|
43193
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
61 |
@Override |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
62 |
String toString(byte[] ba) { |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
63 |
for (byte b : ba) { |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
64 |
if (b < 0) return super.toString(ba); |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
65 |
} |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
66 |
return new String(ba, ISO_8859_1); |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
67 |
} |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
68 |
} |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
69 |
|
43224
355457152ea8
8173072: zipfs fails to handle incorrect info-zip "extended timestamp extra field"
sherman
parents:
43193
diff
changeset
|
70 |
private static final ZipCoder utf8 = new UTF8(); |
43193
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
71 |
|
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
72 |
public static ZipCoder get(String csn) { |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
73 |
Charset cs = Charset.forName(csn); |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
74 |
if (cs.name().equals("UTF-8")) { |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
75 |
return utf8; |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
76 |
} |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
77 |
return new ZipCoder(cs); |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
78 |
} |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
79 |
|
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
80 |
String toString(byte[] ba) { |
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
81 |
CharsetDecoder cd = decoder().reset(); |
43193
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
82 |
int clen = (int)(ba.length * cd.maxCharsPerByte()); |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
83 |
char[] ca = new char[clen]; |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
84 |
if (clen == 0) |
43224
355457152ea8
8173072: zipfs fails to handle incorrect info-zip "extended timestamp extra field"
sherman
parents:
43193
diff
changeset
|
85 |
return new String(ca); |
43193
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
86 |
ByteBuffer bb = ByteBuffer.wrap(ba, 0, ba.length); |
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
87 |
CharBuffer cb = CharBuffer.wrap(ca); |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
88 |
CoderResult cr = cd.decode(bb, cb, true); |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
89 |
if (!cr.isUnderflow()) |
43224
355457152ea8
8173072: zipfs fails to handle incorrect info-zip "extended timestamp extra field"
sherman
parents:
43193
diff
changeset
|
90 |
throw new IllegalArgumentException(cr.toString()); |
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
91 |
cr = cd.flush(cb); |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
92 |
if (!cr.isUnderflow()) |
43224
355457152ea8
8173072: zipfs fails to handle incorrect info-zip "extended timestamp extra field"
sherman
parents:
43193
diff
changeset
|
93 |
throw new IllegalArgumentException(cr.toString()); |
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
94 |
return new String(ca, 0, cb.position()); |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
95 |
} |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
96 |
|
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
97 |
byte[] getBytes(String s) { |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
98 |
CharsetEncoder ce = encoder().reset(); |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
99 |
char[] ca = s.toCharArray(); |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
100 |
int len = (int)(ca.length * ce.maxBytesPerChar()); |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
101 |
byte[] ba = new byte[len]; |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
102 |
if (len == 0) |
43224
355457152ea8
8173072: zipfs fails to handle incorrect info-zip "extended timestamp extra field"
sherman
parents:
43193
diff
changeset
|
103 |
return ba; |
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
104 |
ByteBuffer bb = ByteBuffer.wrap(ba); |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
105 |
CharBuffer cb = CharBuffer.wrap(ca); |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
106 |
CoderResult cr = ce.encode(cb, bb, true); |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
107 |
if (!cr.isUnderflow()) |
43224
355457152ea8
8173072: zipfs fails to handle incorrect info-zip "extended timestamp extra field"
sherman
parents:
43193
diff
changeset
|
108 |
throw new IllegalArgumentException(cr.toString()); |
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
109 |
cr = ce.flush(bb); |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
110 |
if (!cr.isUnderflow()) |
43224
355457152ea8
8173072: zipfs fails to handle incorrect info-zip "extended timestamp extra field"
sherman
parents:
43193
diff
changeset
|
111 |
throw new IllegalArgumentException(cr.toString()); |
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
112 |
if (bb.position() == ba.length) // defensive copy? |
43224
355457152ea8
8173072: zipfs fails to handle incorrect info-zip "extended timestamp extra field"
sherman
parents:
43193
diff
changeset
|
113 |
return ba; |
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
114 |
else |
43224
355457152ea8
8173072: zipfs fails to handle incorrect info-zip "extended timestamp extra field"
sherman
parents:
43193
diff
changeset
|
115 |
return Arrays.copyOf(ba, bb.position()); |
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
116 |
} |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
117 |
|
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
118 |
boolean isUTF8() { |
43193
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
119 |
return cs == UTF_8; |
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
120 |
} |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
121 |
|
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
122 |
private Charset cs; |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
123 |
|
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
124 |
private ZipCoder(Charset cs) { |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
125 |
this.cs = cs; |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
126 |
} |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
127 |
|
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
128 |
private final ThreadLocal<CharsetDecoder> decTL = new ThreadLocal<>(); |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
129 |
private final ThreadLocal<CharsetEncoder> encTL = new ThreadLocal<>(); |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
130 |
|
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
131 |
private CharsetDecoder decoder() { |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
132 |
CharsetDecoder dec = decTL.get(); |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
133 |
if (dec == null) { |
43193
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
134 |
dec = cs.newDecoder() |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
135 |
.onMalformedInput(CodingErrorAction.REPORT) |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
136 |
.onUnmappableCharacter(CodingErrorAction.REPORT); |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
137 |
decTL.set(dec); |
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
138 |
} |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
139 |
return dec; |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
140 |
} |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
141 |
|
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
142 |
private CharsetEncoder encoder() { |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
143 |
CharsetEncoder enc = encTL.get(); |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
144 |
if (enc == null) { |
43193
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
145 |
enc = cs.newEncoder() |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
146 |
.onMalformedInput(CodingErrorAction.REPORT) |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
147 |
.onUnmappableCharacter(CodingErrorAction.REPORT); |
a8e490921d20
8172921: Zip filesystem performance improvement and code cleanup
sherman
parents:
25859
diff
changeset
|
148 |
encTL.set(enc); |
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
149 |
} |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
150 |
return enc; |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
151 |
} |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
152 |
} |