0
FTPClient ftpClient;

ZipOutputStream zipOut = null;   
zipOut = new ZipOutputStream(ftpClient.storeFileStream("a.zip")); 

String str;
byte []conarr=str.getBytes();

zipOut.putNextEntry(new ZipEntry("1.txt")); 
zipOut.write(conarr);
zipOut.close();

If str only has several characters, it's ok, but if str is dozens of kB, the zip file has an error.

ronalchn
  • 12,225
  • 10
  • 51
  • 61
  • You haven't shown how you're populating `str`. Also, you should almost *certainly* not be using `getBytes()` without an encoding. It's entirely possible that you shouldn't be using a string at all. Please edit your code to show a *complete* method, as well as explaining what you're trying to do and *exactly* what goes wrong. Oh, and look at the formatting help. – Jon Skeet Sep 24 '12 at 06:28
  • 1
    What language is this? Please edit your question to include the correct language tag. – Some programmer dude Sep 24 '12 at 06:37

0 Answers0