94 |
/** |
/** |
95 |
* Set the zip file comment. |
* Set the zip file comment. |
96 |
* @param comment the comment. |
* @param comment the comment. |
97 |
* @exception IllegalArgumentException if UTF8 encoding of comment is |
* @exception IllegalArgumentException if encoding of comment is |
98 |
* longer than 0xffff bytes. |
* longer than 0xffff bytes. |
99 |
*/ |
*/ |
100 |
public void setComment(String comment) |
public void setComment(String comment) |
101 |
{ |
{ |
102 |
byte[] commentBytes; |
byte[] commentBytes; |
103 |
try |
commentBytes = comment.getBytes(); |
|
{ |
|
|
commentBytes = comment.getBytes("UTF8"); |
|
|
} |
|
|
catch (UnsupportedEncodingException ex) |
|
|
{ |
|
|
throw new InternalError("UTF8 encoding not found"); |
|
|
} |
|
104 |
if (commentBytes.length > 0xffff) |
if (commentBytes.length > 0xffff) |
105 |
throw new IllegalArgumentException("Comment too long."); |
throw new IllegalArgumentException("Comment too long."); |
106 |
zipComment = commentBytes; |
zipComment = commentBytes; |
224 |
writeLeInt(0); |
writeLeInt(0); |
225 |
writeLeInt(0); |
writeLeInt(0); |
226 |
} |
} |
227 |
byte[] name = entry.getName().getBytes("UTF8"); |
byte[] name = entry.getName().getBytes(); |
228 |
if (name.length > 0xffff) |
if (name.length > 0xffff) |
229 |
throw new ZipException("Name too long."); |
throw new ZipException("Name too long."); |
230 |
byte[] extra = entry.getExtra(); |
byte[] extra = entry.getExtra(); |
355 |
writeLeInt((int)entry.getCompressedSize()); |
writeLeInt((int)entry.getCompressedSize()); |
356 |
writeLeInt((int)entry.getSize()); |
writeLeInt((int)entry.getSize()); |
357 |
|
|
358 |
byte[] name = entry.getName().getBytes("UTF8"); |
byte[] name = entry.getName().getBytes(); |
359 |
if (name.length > 0xffff) |
if (name.length > 0xffff) |
360 |
throw new ZipException("Name too long."); |
throw new ZipException("Name too long."); |
361 |
byte[] extra = entry.getExtra(); |
byte[] extra = entry.getExtra(); |
363 |
extra = new byte[0]; |
extra = new byte[0]; |
364 |
String strComment = entry.getComment(); |
String strComment = entry.getComment(); |
365 |
byte[] comment = strComment != null |
byte[] comment = strComment != null |
366 |
? strComment.getBytes("UTF8") : new byte[0]; |
? strComment.getBytes() : new byte[0]; |
367 |
if (comment.length > 0xffff) |
if (comment.length > 0xffff) |
368 |
throw new ZipException("Comment too long."); |
throw new ZipException("Comment too long."); |
369 |
|
|