public static byte[] fileToZip(){
        ZipOutputStream append = null;
        
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        
        try {
            append = new ZipOutputStream(bos);
            
            ZipEntry e = new ZipEntry("request.xml");
            append.putNextEntry(e);
            append.write(filteToByte("G:\\tmp\\request.xml"));
            append.closeEntry();
            
            e = new ZipEntry("CONTENT\\content.xml");
            append.putNextEntry(e);
            append.write(filteToByte("G:\\tmp\\content.xml"));
            append.closeEntry();
            
        } catch (FileNotFoundException ex) {
            Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex);
        } finally{
            if(null != append){
                try {
                    append.close();
                } catch (IOException ex) {
                    Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
        
        return bos.toByteArray();
    }

 

相关文章:

  • 2021-11-21
  • 2022-02-03
  • 2022-12-23
  • 2021-07-25
  • 2022-03-01
  • 2022-02-07
  • 2022-12-23
  • 2022-02-07
猜你喜欢
  • 2022-01-21
  • 2022-12-23
  • 2021-07-07
  • 2021-08-07
  • 2021-11-28
  • 2022-12-23
  • 2022-01-14
相关资源
相似解决方案