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

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: 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();

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