In Java Corrupted Excel file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Muhammad Zeeshan Iqbal
    New Member
    • Apr 2007
    • 1

    In Java Corrupted Excel file

    Hello,


    Language= Java;
    Platform= Linux;
    Application= Web

    I have help excel file. I download it using FileInputStream .
    When it is downloaded from solaris or widows platform it is correct.
    But when it is downloaded from Linum platform it becomes corrupted.

    Code:
            
    PrintWriter out = new PrintWriter(response.getOutputStream());
    response.setContentType("application/excel");
    response.setHeader("Content-Disposition", "attachment; filename=\a.xls\");
    //Sending the file
        int iRead;
        FileInputStream stream = null;
        File f = new File("a.xls");
        stream = new FileInputStream(f);
    //Writing the stream values 
        while ((iRead = stream.read()) != -1)
        out.write(iRead);
    //Flush the output
        out.flush();
    Kindly, provide me solution.
Working...