<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Read a zip file comment with Java</title>
	<atom:link href="http://www.flattermann.net/2009/01/read-a-zip-file-comment-with-java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.flattermann.net/2009/01/read-a-zip-file-comment-with-java/</link>
	<description>flattermann&#039;s developer blog</description>
	<lastBuildDate>Sun, 11 Sep 2011 00:07:55 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
	<item>
		<title>By: Ivan</title>
		<link>http://www.flattermann.net/2009/01/read-a-zip-file-comment-with-java/comment-page-1/#comment-1739</link>
		<dc:creator>Ivan</dc:creator>
		<pubDate>Sun, 17 Apr 2011 19:43:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.flattermann.net/?p=65#comment-1739</guid>
		<description>I forgot to follow up with my original query.

I solved the problem and posted it here (http://www.coderanch.com/t/530362/Streams/java/Zip-file-archive-comment-extended).

Thought it might help, sorry for the delay.

Ivan</description>
		<content:encoded><![CDATA[<p>I forgot to follow up with my original query.</p>
<p>I solved the problem and posted it here (<a href="http://www.coderanch.com/t/530362/Streams/java/Zip-file-archive-comment-extended" rel="nofollow">http://www.coderanch.com/t/530362/Streams/java/Zip-file-archive-comment-extended</a>).</p>
<p>Thought it might help, sorry for the delay.</p>
<p>Ivan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ivan</title>
		<link>http://www.flattermann.net/2009/01/read-a-zip-file-comment-with-java/comment-page-1/#comment-1623</link>
		<dc:creator>Ivan</dc:creator>
		<pubDate>Fri, 11 Mar 2011 16:42:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.flattermann.net/?p=65#comment-1623</guid>
		<description>I am having the reverse problem with my code.

I am trying to figure out how to write the registered trademark &#039;®&#039; and copyright character &#039;©&#039; to the archive comment for a zip file. This is not a comment for the ZipEntry, although the solution may be similar; but, rather, the whole zip file comment, as you have retrieved in your example above.

I have tried a lot of different things; but, at the end of the day, the setComment() method on the JarOutputStream (which extends ZipOutputStream) writes a &quot;circumflex a&quot; (i.e., an &#039;Â&#039;) before the extended ASCII characters. 

So, instead of: 

MySoftware® 
Copyright © 2011 

I get: 

MySoftwareÂ® 
Copyright Â© 2011 

when viewing the archive comments using WinZip or PKZIP or 7-ZIP or any other archive tool I have tried (including your code above). 

I have tried converting to Unicode; but, since the setComment() implementation only writes single bytes, I get a literal &#039;\u00A9&#039; string in the comment. 

Can you tell me how to write (and/or replace) the comments to a zip file without using the setComment() method.  I have tried appending the comment directly to the end of the file using other suggestions; but I am somehow corrupting the archive when doing so. 

I know that I could simply use &#039;(R)&#039; and &#039;(c)&#039; instead, but I would rather use the extended ASCII characters, as they look better. I also know that this can be done via WinZip&#039;s command line utility; but I would like to use Java so I don&#039;t have to buy a zip license just to add an archive comment to a jar file.   I also know that this might have been fixed with Java 7 (with the addition of Charset arg in constructor); but I must use 1.6 for the time being.

Thank you in advance for any help you can offer.</description>
		<content:encoded><![CDATA[<p>I am having the reverse problem with my code.</p>
<p>I am trying to figure out how to write the registered trademark &#8216;®&#8217; and copyright character &#8216;©&#8217; to the archive comment for a zip file. This is not a comment for the ZipEntry, although the solution may be similar; but, rather, the whole zip file comment, as you have retrieved in your example above.</p>
<p>I have tried a lot of different things; but, at the end of the day, the setComment() method on the JarOutputStream (which extends ZipOutputStream) writes a &#8220;circumflex a&#8221; (i.e., an &#8216;Â&#8217;) before the extended ASCII characters. </p>
<p>So, instead of: </p>
<p>MySoftware®<br />
Copyright © 2011 </p>
<p>I get: </p>
<p>MySoftwareÂ®<br />
Copyright Â© 2011 </p>
<p>when viewing the archive comments using WinZip or PKZIP or 7-ZIP or any other archive tool I have tried (including your code above). </p>
<p>I have tried converting to Unicode; but, since the setComment() implementation only writes single bytes, I get a literal &#8216;\u00A9&#8242; string in the comment. </p>
<p>Can you tell me how to write (and/or replace) the comments to a zip file without using the setComment() method.  I have tried appending the comment directly to the end of the file using other suggestions; but I am somehow corrupting the archive when doing so. </p>
<p>I know that I could simply use &#8216;(R)&#8217; and &#8216;(c)&#8217; instead, but I would rather use the extended ASCII characters, as they look better. I also know that this can be done via WinZip&#8217;s command line utility; but I would like to use Java so I don&#8217;t have to buy a zip license just to add an archive comment to a jar file.   I also know that this might have been fixed with Java 7 (with the addition of Charset arg in constructor); but I must use 1.6 for the time being.</p>
<p>Thank you in advance for any help you can offer.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shirkit</title>
		<link>http://www.flattermann.net/2009/01/read-a-zip-file-comment-with-java/comment-page-1/#comment-849</link>
		<dc:creator>Shirkit</dc:creator>
		<pubDate>Fri, 15 Oct 2010 09:36:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.flattermann.net/?p=65#comment-849</guid>
		<description>Dude, did you knew this code just saved my life? I knew there was a magic secret to read zip comments. But I had to make a few changes for this code to work:

First, put an if the commentLen is &gt; 0, then multiply it by -1 (yes, avoid negative values) (after line 45).
Second, changed line 52. realLen was always returning 10 bytes smaller than the realLen of the comment. So, I just removed that Math.min and put just commentLen.</description>
		<content:encoded><![CDATA[<p>Dude, did you knew this code just saved my life? I knew there was a magic secret to read zip comments. But I had to make a few changes for this code to work:</p>
<p>First, put an if the commentLen is &gt; 0, then multiply it by -1 (yes, avoid negative values) (after line 45).<br />
Second, changed line 52. realLen was always returning 10 bytes smaller than the realLen of the comment. So, I just removed that Math.min and put just commentLen.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

