ByteArrayInputStream de imagem virar imagem dentro de um zip

0 respostas
douglasmanteiga
ByteArrayInputStream byt = new ByteArrayInputStream(img);

Esse img que está dentro do ByteArray era um blob que transformei em Byte e depois
joguei no ByteArrayInputStream... agora como faço para transformar esse byt em uma imagem dentro de um arquivo zip...

Consegui esse código abaixo mais ele está criando a imagem no HD preciso que saia em um arquivo ZIP alguem poderia me ajudar alterar de forma correta?

else {
                //FileInputStream in = new FileInputStream(files[i]);
                //ByteArrayInputStream byt = new ByteArrayInputStream(img);

                String path = "";
                for (File parentDir : parentDirs) {
                    path += parentDir.getName() + "/";
                }
                ByteArrayOutputStream outt = new ByteArrayOutputStream();
                InputStream in = usu.getImageBlob().getBinaryStream();
                OutputStream outputStream = new FileOutputStream("C:/temp/a.jpg");
                //OutputStream outputStream = new FileOutputStream("a.jpg");

                int length = (int) usu.getImageBlob().length();
                int bufferSize = 1024;

                byte[] buffer = new byte[bufferSize];

                while ((length = in.read(buffer)) != -1) {
                    System.out.println("writing " + length + " bytes");
                    outt.write(buffer, 0, length);
                }
                outt.writeTo(outputStream);
                //in.close();
             
                
                
                
                ZipEntry arquivos = new ZipEntry("Arquivos/" + outt);
                        //+ path + files[i].getName());
                out.putNextEntry(arquivos);
                
                out.closeEntry();
                //in.close();
            }
Criado 31 de outubro de 2012
Respostas 0
Participantes 1