jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tobias Bocanegra" <tobias.bocane...@day.com>
Subject Re: General Packaging mechanism
Date Wed, 21 Feb 2007 19:33:46 GMT
correct.
i created a small test class that writes and reads from a jar file.
and everything works ok. no matter whatever platform-encoding i use on
my system.
so, i see no problem using the zip-io from jdk1.4.

regards, toby

public class JarTest {

    public static void main(String[] args) throws Exception {
        System.out.println("System file.encoding: " +
System.getProperty("file.encoding"));
        // write entries
        byte[] testBuffer = "Hello, world.\n".getBytes();
        FileOutputStream out = new FileOutputStream("test.jar");
        ZipOutputStream zout = new ZipOutputStream(out);
        ZipEntry e = new ZipEntry("\u03b1 - first.txt");
        zout.putNextEntry(e);
        zout.write(testBuffer);
        zout.closeEntry();
        e = new ZipEntry("\u03b2 - second.txt");
        zout.putNextEntry(e);
        zout.write(testBuffer);
        zout.closeEntry();
        e = new ZipEntry("\u263a - smile.txt");
        zout.putNextEntry(e);
        zout.write(testBuffer);
        zout.closeEntry();
        zout.close();
        out.close();

        // reopen and read entries
        FileInputStream in = new FileInputStream("test.jar");
        ZipInputStream zin = new ZipInputStream(in);
        while ((e = zin.getNextEntry()) != null) {
            System.out.println(e.getName());
        }
        zin.close();
        in.close();
    }
}

-- 
-----------------------------------------< tobias.bocanegra@day.com >---
Tobias Bocanegra, Day Management AG, Barfuesserplatz 6, CH - 4001 Basel
T +41 61 226 98 98, F +41 61 226 98 97
-----------------------------------------------< http://www.day.com >---

Mime
View raw message