net.i2p.util
Class ZipFileComment
java.lang.Object
net.i2p.util.ZipFileComment
public abstract class ZipFileComment
- extends Object
Not available in ZipFile until Java 7. Refs:
https://secure.wikimedia.org/wikipedia/en/wiki/ZIP_%28file_format%29
http://download.oracle.com/javase/1.5.0/docs/api/java/util/zip/ZipFile.html
http://bugs.sun.com/view_bug.do?bug_id=6646605
Code modified from:
http://www.flattermann.net/2009/01/read-a-zip-file-comment-with-java/
Beerware.
since 0.8.8
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ZipFileComment
public ZipFileComment()
getComment
public static String getComment(File file,
int max)
throws IOException
- Parameters:
max
- The max length of the comment in bytes.
If the actual comment is longer, it will not be found and
this method will throw an IOE
- Returns:
- empty string if no comment, or the comment.
The string is decoded with UTF-8
- Throws:
IOE
- if no valid end-of-central-directory record found
IOException
getComment
public static String getComment(File file,
int max,
int skip)
throws IOException
- Parameters:
max
- The max length of the comment in bytes.
If the actual comment is longer, it will not be found and
this method will throw an IOEskip
- Number of bytes to skip in the file before looking for the
zip header. Use 56 for sud/su2 files.
- Returns:
- empty string if no comment, or the comment.
The string is decoded with UTF-8
- Throws:
IOE
- if no valid end-of-central-directory record found
IOException
main
public static void main(String[] args)
throws IOException
- Throws:
IOException