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

                }

            }

        }

    }

 

你可能感兴趣的:(poi3.8)