Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

zipEntry.getComment() returns null

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All.
I have some troubles with zip files.
When I compressing some files I add comment to each ZipEntry:
ZipEntry zipEntry = new ZipEntry(files[i]);
zipEntry.setComment("Comment fo " + files[i]);
zos.putNextEntry(zipEntry);
But when I read archive back,
zipEntry.getComment()
returns null.
I want to write some information about files format in comments, to parse files after extraction.
Please help me.

 
Yehor Mikhaylov
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
soliloquize.
I have found solution.
setComment() and getComment() don't work.
But there are methods that can do their work:
public void setExtra(byte[] extra)
public byte[] getExtra()
All u need is to convert your string into byte array and then byte array into string.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can try
zipEntry = (new ZipFile(arcName)).getEntry(zipEntry.getName);

zipEntry.getComment(); // it's work for me

Have fun!!
 
Marshal
Posts: 74390
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch
 
reply
    Bookmark Topic Watch Topic
  • New Topic