public inbox for java-prs@sourceware.org
help / color / mirror / Atom feed
From: "wayne dot gray at coynetextileservices dot com" <gcc-bugzilla@gcc.gnu.org>
To: java-prs@gcc.gnu.org
Subject: [Bug libgcj/19109] New: Creating archives with java.util.zip
Date: Tue, 21 Dec 2004 14:41:00 -0000	[thread overview]
Message-ID: <20041221144153.19109.wayne.gray@coynetextileservices.com> (raw)

The below code produces a zip file that can be opened in WinZip 8.1 when
compiled with Sun JRE 1.4.1_01.  When compiled with GCJ 3.4.0 the zip file is
produced but WinZip says it's corrupt.

Is this a bug in GCJ or am I misunderstanding how java.util.zip works in libgcj?

Thanks.

Usage:  Pass in two arguments to class.  First arg is name of archive and second
is the name of the file you want to add to the archive.

************************************************************************

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.zip.Deflater;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

public class ZipMain {

	/**
	 * 
	 */
	public ZipMain() {
		super();
	}

	public static void main(String[] args) {
	
		String sArchive = args[0];
		String sFile = args[1];
		
		if (sArchive==null || sFile==null || 
				sArchive.length()==0 || sFile.length()==0){
			return;
		}
		
		File f = new File(sFile);
		
		if (!f.exists()){
			return;
		}
		
		ZipOutputStream oArchive = null;
		File fArchive = new File(sArchive);

		try {
			//open archive
			oArchive = new ZipOutputStream(new FileOutputStream(fArchive));
				oArchive.setLevel(Deflater.DEFAULT_COMPRESSION);
			
				//add file
				
			ZipEntry zipEntry = new ZipEntry(f.toString());
			FileInputStream fin = new FileInputStream(f);
			BufferedInputStream in = new BufferedInputStream(fin);
			oArchive.putNextEntry(zipEntry);

			byte[] buf = new byte[1024];
			int len;
			while ((len = in.read(buf)) >= 0) {
				oArchive.write(buf, 0, len);
			}
			
			//clean up
			in.close();
			oArchive.closeEntry();
			oArchive.close();
			
		} catch (Exception e){
			e.printStackTrace();
		}
		
	}
}

-- 
           Summary: Creating archives with java.util.zip
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libgcj
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: wayne dot gray at coynetextileservices dot com
                CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu
                    dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19109


             reply	other threads:[~2004-12-21 14:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-21 14:41 wayne dot gray at coynetextileservices dot com [this message]
2004-12-21 14:48 ` [Bug libgcj/19109] " belyshev at lubercy dot com
2004-12-21 15:48 ` pinskia at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20041221144153.19109.wayne.gray@coynetextileservices.com \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=java-prs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).