简单实现,之后会有详细的实现,看需求,简单需求就可以用,解决了乱码问题,样式问题下一篇会写
public static void main(String[] args) { //HtmlToDocByFr(getByteArrayInputStream()); String html = getHtml(); writeWordFile(html); }
public static ByteArrayInputStream getByteArrayInputStream() { String path = "/Desktop/234444.html"; try { FileInputStream inputStream = new FileInputStream(path); StringBuffer content = new StringBuffer(); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); while (reader.ready()) { String line = reader.readLine(); content.append(line); } byte by[] = content.toString().getBytes("UTF-8"); ByteArrayInputStream bais = new ByteArrayInputStream(by); return bais; } catch (IOException e) { e.printStackTrace(); } return null; }