简体   繁体   中英

My requirement is to upload static xfa form,but it is not opening immediately

    try {
            OutputStream out = new FileOutputStream(new File(
                    uploadedFileLocation));
            int read = 0;
            byte[] bytes = new byte[1024];

            out = new FileOutputStream(new File(uploadedFileLocation));
            while ((read = uploadedInputStream.read(bytes)) != -1) {
                out.write(bytes, 0, read);


            }
            out.flush();
            out.close();
            uploadedInputStream.close();

            resultfileData = dao.insertRecord(fileData);
            resultfileData.setStatus("success");


        } catch (IOException e) {
            resultfileData.setStatus("failure");
            throw e;
        }
    return resultfileData;

i am able to upload the file successfully.But when i try to open the file it shows the below message"There was an error opening this document.This file already open or in use by another application" please let me know is there any good approach to upload static Xfa form

You are opening the stream out twice and the first one is not closed.

Try to remove row out = new FileOutputStream(new File(uploadedFileLocation)); . It is not necessary.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM