469,344 Members | 6,511 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,344 developers. It's quick & easy.

Error in reading from a file

hi
I have written a code for writing the data of a column from database into a file
and again reading that file and displaying.

Im writing into an .html file....Now the problem is im getting the output but that output is followed by an error.....

This is the output
-----------------------------
A large number of processes are available, and can be applied to an input or a group of inputs. These processes can be chained ogether so that the output from one process is used as an input to another process. In this manner multiple processes may be applied to an input .Error 500: Server caught unhandled exception from servlet [JSP 1.2 Processor]: getCompressingOutputStream() has already been called

Im not able to find wheres the mistake....Here is the code related to it

Expand|Select|Wrap|Line Numbers
  1. String strPath="\\\\enggsw-061\public\\LLDatabase\\suggestions\\textfile1.html";
  2. response.setContentType("APPLICATION/OCTET-STREAM");
  3. //writing into a file
  4.  File f=new File(strPath);
  5.  FileOutputStream fop=new FileOutputStream(f);
  6.  {
  7.         if(f.exists())
  8.         {
  9.       String struggestion=cLessonsLearntSearchActionForm.getSuggestions();
  10.      fop.write(strSuggestion.getBytes());
  11.      fop.flush();
  12.      fop.close();
  13.        }
  14.        else{
  15.         some error message
  16.              } 
  17.  }
  18. //reading the file
  19. FileInputStream fileIn = new FileInputStream(f);
  20. OutputStream out = response.getOutputStream();
  21. {
  22.       byte[] buffer = new byte[2048];
  23.       int bytesRead = fileIn.read(buffer);
  24.       while (bytesRead >= 0) {
  25.       if (bytesRead > 0)
  26.      out.write(buffer, 0, bytesRead);                          bytesRead = fileIn.read(buffer);
  27.     }
  28.        out.flush();
  29.        out.close();
  30.        fileIn.close();
  31. }
  32.  
Thanks
Feb 11 '08 #1
4 1854
r035198x
13,262 8TB
Use a PrintWriter for writing the data. It's text isn't it?
Feb 11 '08 #2
BigDaddyLH
1,216 Expert 1GB
Please enclose your posted code in [code] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use [code] tags in future.

MODERATOR
Feb 11 '08 #3
Use a PrintWriter for writing the data. It's text isn't it?
Hi
This helped me fine...Now there is no such error... everything is working fine..

Thank You
Feb 13 '08 #4
r035198x
13,262 8TB
Hi
This helped me fine...Now there is no such error... everything is working fine..

Thank You
The right tool for the right job ...
Feb 13 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by GB | last post: by
reply views Thread by Rhon Stewart via DotNetMonster.com | last post: by
1 post views Thread by RADAR | last post: by
1 post views Thread by Steve Ametjan | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.