You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by bo...@apache.org on 2009/02/19 18:23:07 UTC
svn commit: r745933 -
/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
Author: bodewig
Date: Thu Feb 19 17:23:05 2009
New Revision: 745933
URL: http://svn.apache.org/viewvc?rev=745933&view=rev
Log:
NIO doesn't recognize all encoding names that String.getBytes does, strange. At least it fails for 'UnicodeBig' on my Java 1.4 installation
Modified:
commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java?rev=745933&r1=745932&r2=745933&view=diff
==============================================================================
--- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java (original)
+++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java Thu Feb 19 17:23:05 2009
@@ -904,14 +904,25 @@
* this Stream.
* @param name the string to get bytes from
* @return the bytes as a byte array
+ * @throws ZipException on error
*
* @since 1.3
*/
- protected byte[] getBytes(String name) {
+ protected byte[] getBytes(String name) throws ZipException {
if (encoding == null) {
return name.getBytes();
} else {
- return ZipEncodingHelper.encodeName(name, encoding);
+ try {
+ return ZipEncodingHelper.encodeName(name, encoding);
+ } catch (java.nio.charset.UnsupportedCharsetException ex) {
+ // Java 1.4's NIO doesn't recognize a few names that
+ // String.getBytes does
+ try {
+ return name.getBytes(encoding);
+ } catch (UnsupportedEncodingException uee) {
+ throw new ZipException(uee.getMessage());
+ }
+ }
}
}