473,379 Members | 1,533 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Error in reading from a file

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. }
Feb 11 '08 #1
4 2124
13,262 8TB
Use a PrintWriter for writing the data. It's text isn't it?
Feb 11 '08 #2
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.

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

Thank You
Feb 13 '08 #4
13,262 8TB
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

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

Similar topics

by: TTroy | last post by:
Hello, I have found some peculiar behaviour in the fgets runtime library function for my compiler/OS/platform (Dev C++/XP/P4) - making a C console program (which runs in a CMD.exe shell). The...
by: GB | last post by:
Hi Everybody! I have 2 different processes/application. One is writing to a file and another is reading from it. For some reason the code doesnt seems to work and gives mscorlib.dll IOException...
by: Rhon Stewart via DotNetMonster.com | last post by:
Hi please visit this link : http://www.eggheadcafe.com/articles/pfc/selfupdater.asp I followed all the steps for listed on the link , when I execute the application it it gives me the following...
by: moondaddy | last post by:
I have an application where users need to upload images and in my web.config file I have a setting like this: <httpRuntime maxRequestLength="512" /> Which restricts image larger than 500k from...
by: Mart | last post by:
Hi, I have just written (my first) VB.net app using MS Visual Basic 2005 Express Edition Beta. It is fairly simple, it reads some configuration data from an XML file then opens a new window...
by: tgnelson85 | last post by:
Hello, C question here (running on Linux, though there should be no platform specific code). After reading through a few examples, and following one in a book, for linked lists i thought i would...
by: RADAR | last post by:
hi, the error code was taken from msdn and it occured in my code as follows; i am reading buffer from the file : #include <stdio.h> #include <stdlib.h> #define SIZE 10 #define DSIZE 5...
by: Steve Ametjan | last post by:
I've been trying to get MySQL-python to install on Leopard for the past couple of days, and I keep running into relatively the same error. I'm hoping that someone on this list will be able to...
Guido Geurs
by: Guido Geurs | last post by:
I'm writing a program that list the contents of a CDrom and also the contents of the ZIP files. When there is a bad Zip file on the CD, the program keeps traying to reed the file and after +- 50...
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.