我有以下情况 我要修改现有的文件,并返回一个包含该修改文件的zip,我在web应用上下文中的zip文件 什么,我做了现在是:创建阿拉伯字符
///////////////// 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("<nomPrenom>","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 < b.length; j++) {
out.write(b[j]);
}
创建的压缩文件不能被正确地字考虑到原始文件在阿拉伯语
wrotten我想这个阅读:
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("<nomPrenom>","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 < stream.length; j++) {
writer.write(stream[j]);
}
writer.close();
} catch (IOException e) {
System.out.println(e.toString());
}
它不工作
看一看这个答案: http://stackoverflow.com/questions/2260325/why-is-java-bufferedreader-not-reading-arabic-and-chinese-characters-correctly – dngfng
我不要认为这是编码的问题,因为我尝试与法国文件,我认为这是正确阅读流的问题 – fatiDev