poi3.8 word

word转换

public void createTemp(String fileString,File docFile) {
        HWPFDocument hwpfDocument = null;
        FileInputStream fis = null;
        FileOutputStream fos = null;
        ByteArrayOutputStream bos = null;
        try {
            fis = new FileInputStream(new File(fileString));
            fos = new FileOutputStream(docFile, true);
            bos = new ByteArrayOutputStream();
            hwpfDocument = new HWPFDocument(fis);
            hwpfDocument.write(bos);

            fos.write(bos.toByteArray());
            bos.flush();
            fos.flush();
        } catch (FileNotFoundException e) {
                        e.printStackTrace();
        } catch (IOException e) {
                        e.printStackTrace();
        } finally {
            if (null != fis) {
                try {
                    fis.close();
                } catch (IOException e) {                    e.printStackTrace();
                }
            }
            if (null != bos) {
                try {
                    bos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (null != fos) {
                try {
                    fos.close();
                } catch (IOException e) {
                                    e.printStackTrace();
                }
            }
        }
    }
原文地址:https://www.cnblogs.com/xiaoxian1369/p/2740850.html