outputstream for downloadfile

UI Components for JSF
Post Reply
trap12
Posts: 12
Joined: 31 Aug 2014, 13:12

31 Aug 2014, 13:22

Hi,

I wanted to download an excel file. But for the download I need an InputStream, but I have an OutPutStream. By convertig output to input i got several exceptions.

Code: Select all

        File tempFile = File.createTempFile("tempFile", ".xslx");
        OutputStream out = new FileOutputStream(tempFile);
        createFile.writeReport(out);
        out.close();
        
        InputStream istream = new FileInputStream(tempFile);
        setFile(new DefaultStreamedContent(istream, "application/vnd.ms-excel", "file.xslx"));
        istream.close();
        tempFile.delete();
have you any idea how can I use only the outputStream?

thank you in advance!

trap12

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 9 guests