Using GZIP streams to compress

First time poster, long time reader

I'm trying to write some serializable objects (ArrayLists) to file, but I wanted to compress them first. The GZIP stream isn't doing anything, even when it should. How should I be using it? Thanks if you can help

public void save( String filename )

{

try {

File file = new File( filename );

FileOutputStream outStream = new FileOutputStream( file );

GZIPOutputStream zipOut = new GZIPOutputStream( outStream );

ObjectOutputStream out = new ObjectOutputStream( zipOut );

out.writeObject( xList );

out.writeObject( yList );

out.writeObject( list );

out.close();

} catch (IOException e) {

System.exit( 1 );

}

}

[748 byte] By [avdokreissa] at [2007-10-2 15:59:38]
# 1
I can't figure out how to delete posts, but I figured it out. I was working on a java file of the same name in another directory and so it kept using the one I wasn't working on.On another note, what is the best way to turn a byte array into an int array and vice versa?
avdokreissa at 2007-7-13 16:26:10 > top of Java-index,Other Topics,Algorithms...
# 2

> On another note, what is the best way to turn a byte

> array into an int array and vice versa?

Check out the ByteBuffer class:

ByteBuffer byteBuffer = ByteBuffer.wrap(byteArray);

IntBuffer intBuffer = byteBuffer.asIntBuffer();

// then you can do:

int i = intBuffer.get(i);

Hope this helps.

nbloma at 2007-7-13 16:26:10 > top of Java-index,Other Topics,Algorithms...
# 3
Thanks.
avdokreissa at 2007-7-13 16:26:10 > top of Java-index,Other Topics,Algorithms...