现在的位置: 首页 > 综合 > 正文

poi3.8 word

2012年06月06日 ⁄ 综合 ⁄ 共 717字 ⁄ 字号 评论关闭

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();
                }
            }
        }
    }

 

抱歉!评论已关闭.