purtroppo sto ancora impazzendo...
ho fatto un pò di prove ma ottengo:
java.util.zip.ZipException: invalid entry compressed size (expected 358 but got 341 bytes)
di seguito la porzione di codice:
in pratica sto provando a estrarre il contenuto del docx e trasferirlo in un altro.codice:try { ZipInputStream zis = new ZipInputStream(new FileInputStream("c:/test_richiedente.docx") ); ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream( new FileOutputStream("c:/test_richiedenteOK.docx"))); ZipEntry entry; String Dir = "c:/word"; boolean success = (new File(Dir)).mkdir(); if(success) System.out.println("Cartella creata"); FileOutputStream file = new FileOutputStream("c:/word/file.txt"); while((entry = zis.getNextEntry()) != null) { System.out.println(entry.getName()); zos.putNextEntry(entry); int count; byte[] data = new byte[1024]; while((count = zis.read(data,0,1024)) != -1) { zos.write(data, 0, count); } zos.flush(); BufferedReader br = new BufferedReader(new InputStreamReader(zis)); String s; while((s=br.readLine())!=null){ if(s.contains("$data$")){ //System.out.println(s); s = s.replace("$data$", "ok funge"); //System.out.println(s); //fw.write(s); } } } zis.close(); }

Rispondi quotando