Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Java: bytearray to files, then to ZIP

Name: enterprise toilet scrubber 2012-05-17 16:27

Dear faggots

I have some files stored in a database. I want to recover all these files and return a zip file containing all the files.

So, i have this

(rs is the result set with the bytes on the "data" field)


ArrayList<byte[]> attachment = new ArrayList<byte[]>();
ArrayList<ByteArrayInputStream> entries = new ArrayList<ByteArrayInputStream>();

while(rs.next()) {
  ByteArrayInputStream entry = new ByteArrayInputStream(rs.getBytes("data"));
  entries.add(entry);
}


What i need is to create a ZIP file that contains the elements of the entries array.

Thanks!

Name: Anonymous 2012-05-17 20:00

Dear faggots
/polecat kebabs/

Name: OP 2012-05-18 15:00

Solved...

            ZipOutputStream zos = new ZipOutputStream(out);
           
            while (rs.next()) {
                ZipEntry ze = new ZipEntry(rs.getString("valor_s"));
                ze.setSize(rs.getBytes("valor_b").length);
                zos.putNextEntry(ze);
                zos.write(rs.getBytes("valor_b"));
                zos.closeEntry();
            }
            zos.close();
                        return out.toByteArray();

Name: OP 2012-05-18 15:02

>>3
valor_s is the original name of the "file" inserted in the Zip
valor_b is the raw data

Name: bampu pantsu 2012-05-29 5:02

bampu pantsu

Name: Sgt.Kabuὄ큈kiman耹 2012-05-29 13:32

Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy

Don't change these.
Name: Email:
Entire Thread Thread List