从网上找了这个方法,可以写成功文档,但是文档内容会乱码,请大神赐教
String uContent = “<html><p style="text-indent: 2em; text-align: center;"><span style="font-size: 20px;"><strong>标题</strong></span><br/></p><p style="text-indent: 2em;">我想要3个<em>苹果</em>。</p></html>;
byte b[] = uContent.getBytes("utf-8");
ByteArrayInputStream bais = new ByteArrayInputStream(b);
//生成Word文档
POIFSFileSystem poifs = new POIFSFileSystem();
DirectoryEntry directory = poifs.getRoot();
DocumentEntry documentEntry = directory.createDocument("WordDocument", bais);//生成word
FileOutputStream ostream = new FileOutputStream(WordPath);
poifs.writeFilesystem(ostream);//把文档写到指定位置
bais.close();
ostream.close();
这是文档乱码的样子