Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How can I rename a ZIP File??

807580Dec 2 2009 — edited Dec 2 2009
Hi all,
I need to create a Zip file and once it's created, I have to change it's name. The code I've developed is the following:

String[] filenames = new String[]{"newUsers.csv"};
        byte[] buf = new byte[1024];

        try {

            ZipOutputStream out = new ZipOutputStream( new FileOutputStream("newUsers.zip"));

            for (int i=0; i<filenames.length; i++){
                FileInputStream in = new FileInputStream(filenames);
out.putNextEntry(new ZipEntry(filenames[i]));
int len;
while ((len = in.read(buf)) > 0){
out.write(buf, 0, len);
}
out.closeEntry();
in.close();
}
out.close();
} catch (IOException e) {
e.printStackTrace();
}
This code creates my ZIP, what do I have to do to change it's name once it's finished? I home that someone can help me, it's quite urgent                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 30 2009
Added on Dec 2 2009
8 comments
2,450 views