In Java: How to zip file from byte[] array?

前端 未结 7 2322
情话喂你
情话喂你 2020-11-28 03:36

My application is receiving email through SMTP server. There are one or more attachments in the email and email attachment return as byte[] (using sun javamail api).

7条回答
  •  春和景丽
    2020-11-28 03:45

    ByteArrayInputStream bais = new ByteArrayInputStream(retByte);
                    
    ZipInputStream zis = new ZipInputStream(bais);
               
    zis.getNextEntry();
    
    Scanner sc = new Scanner(zis);
    while (sc.hasNextLine()) {
        System.out.println("-->:" +sc.nextLine());
    }
    
    zis.closeEntry();
    zis.close();
    

提交回复
热议问题