Note that there are some explanatory texts on larger screens.

plurals
  1. POcreate zip files with arabic characters
    text
    copied!<p>i have the following situation i have to modify an existing files and return a zip containing this modified files , i'm in web application context what i done up to now is : </p> <pre><code>///////////////// modifying the existing file with poi librairy FileInputStream inpoi = new FileInputStream("file_path"); POIFSFileSystem fs = new POIFSFileSystem(inpoi); HWPFDocument doc = new HWPFDocument(fs); Range r = doc.getRange(); r.replaceText("&lt;nomPrenom&gt;","test"); byte[] b = doc.getDataStream(); //////////////////////// create the zip file and copy the modified files into it ZipOutputStream out = new ZipOutputStream(new FileOutputStream("my.zip")); out.putNextEntry(new ZipEntry("file")); for (int j = 0; j &lt; b.length; j++) { out.write(b[j]); } </code></pre> <p>the created zipped file can't be read correctly with word given that the original file is wrotten in arabic </p> <p>i tried to this : </p> <pre><code> try { FileInputStream inpoi = new FileInputStream("C:\\Users\\free\\Desktop\\myworkspace\\gestionRH\\WebRoot\\fiches\\blame.doc"); POIFSFileSystem fs = new POIFSFileSystem(inpoi); HWPFDocument doc = new HWPFDocument(fs); Range r = doc.getRange(); r.replaceText("&lt;nomPrenom&gt;","test"); byte[] stream= doc.getDataStream(); String encoding = "utf-16"; ZipOutputStream out = new ZipOutputStream(new FileOutputStream("yyy.zip")); ZipEntry zipEntry = new ZipEntry("file.doc"); OutputStreamWriter writer = new OutputStreamWriter(out,"utf-8"); out.putNextEntry(zipEntry); for (int j = 0; j &lt; stream.length; j++) { writer.write(stream[j]); } writer.close(); } catch (IOException e) { System.out.println(e.toString()); } </code></pre> <p>it doesn't work </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload