473,756 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error in reading from a file

49 New Member
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]: getCompressingO utputStream() 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 2149
r035198x
13,262 MVP
Use a PrintWriter for writing the data. It's text isn't it?
Feb 11 '08 #2
BigDaddyLH
1,216 Recognized Expert Top Contributor
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
radhikams
49 New Member
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 MVP
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

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

Similar topics

20
7905
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 standard says about fgets: synopsis #include <stdio.h> char *fgets(char *s, int n, FILE *stream);
2
4068
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 error "This file is being used by another process". Both the applications are in C#. P.S. Even if I try to open the file with NotePad (while my server is writing data in the file)it gives the same error.
0
5003
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 error on the log file: --- ApplicationUpdateManager.StartUpdater] : The Updater has started; the target application's name is 'SayHello'. Time started: 2005_03_01_14:33:21.
25
17214
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 being uploaded. I'm also using the HtmlInputFile control to do the uploading. My problem is that when the user's file size exceeds 512k, the page immediately redirects to the "The page cannot be displayed" error page which is very confusing. ...
0
3588
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 containing a WebBrowser object. This all works fine and I'm happy with my app so I want to 'publish' to a setup file so that others can install it, but when I publish it a get the following errors:
6
4158
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 try my own small program. The problem is, I seem to be having trouble with memory, i.e. sometimes my program will work and display the correct output, and sometimes it will not and display garbage (in a printf call) so i assume i have been using...
1
3930
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 #define DEPTH 150
1
3015
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 help me out in solving the issue. I'd like to get this solved so I can continue developing with Django using MySQL since that's what my web server uses as well. I'd hate to have to develop using a different database engine on my local...
0
1770
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 times it gives the error and ends the function. This function is called from an other function that scans al the files on the disc. Is it possible to give an error but that the program continues with the next file ? =============================...
0
9456
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9872
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8713
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5142
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.