473,888 Members | 1,558 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem in reading line after exception

4 New Member
i am reading a file line by line...But in some case some exception comes,i catch exception but program not exceute next line.Van u please tell how skip the exception comes on line and exceute next line.I used this but it shows compilation error
finally{
continue;
}
but it shows compilation error can u help me...
try {


FileInputStream fstream = new FileInputStream (args[0]);
log");
System.out.prin tln(fstream);
FileOutputStrea m fstream1 = new FileOutputStrea m("C://Documents and Settings/sp0c5899/Desktop/msgtracking.log ");
DataInputStream in = new DataInputStream (fstream);
BufferedReader br = new BufferedReader( new InputStreamRead er(in));
DataOutputStrea m out = new DataOutputStrea m(fstream1);
BufferedWriter br1 = new BufferedWriter( new OutputStreamWri ter(out));
try {

System.out.prin tln("Line 1 : " + lin);


while ((line = br.readLine()) !=null)
{

some condition checking

}
catch (Exception e) {//Catch exception if any
System.err.prin tln("Error: " + e);
e.printStackTra ce();



}


} catch (Exception e) {//Catch exception if any
System.err.prin tln("Error: " + e);
}
finally{
continue;
}
}
Nov 14 '06 #1
5 3036
r035198x
13,262 MVP
i am reading a file line by line...But in some case some exception comes,i catch exception but program not exceute next line.Van u please tell how skip the exception comes on line and exceute next line.I used this but it shows compilation error
finally{
continue;
}
but it shows compilation error can u help me...
try {


FileInputStream fstream = new FileInputStream (args[0]);
log");
System.out.prin tln(fstream);
FileOutputStrea m fstream1 = new FileOutputStrea m("C://Documents and Settings/sp0c5899/Desktop/msgtracking.log ");
DataInputStream in = new DataInputStream (fstream);
BufferedReader br = new BufferedReader( new InputStreamRead er(in));
DataOutputStrea m out = new DataOutputStrea m(fstream1);
BufferedWriter br1 = new BufferedWriter( new OutputStreamWri ter(out));
try {

System.out.prin tln("Line 1 : " + lin);


while ((line = br.readLine()) !=null)
{

some condition checking

}
catch (Exception e) {//Catch exception if any
System.err.prin tln("Error: " + e);
e.printStackTra ce();



}


} catch (Exception e) {//Catch exception if any
System.err.prin tln("Error: " + e);
}
finally{
continue;
}
}
Post code for the whole class and explain your problem again
Nov 14 '06 #2
loveme
4 New Member
Post code for the whole class and explain your problem again
it is part of code problem occured...My problem is that iam reading file line by line and done some condition based on index of a string.some case it create string index out of bound exception..Ie not a problem but after string index out of bound exception the program will not exceute next line and terminate.ineed to read next line and program not terminate .....i put continue on finally it will not work..can u please specify any other solution
Nov 14 '06 #3
r035198x
13,262 MVP
it is part of code problem occured...My problem is that iam reading file line by line and done some condition based on index of a string.some case it create string index out of bound exception..Ie not a problem but after string index out of bound exception the program will not exceute next line and terminate.ineed to read next line and program not terminate .....i put continue on finally it will not work..can u please specify any other solution
Do not put continue in finally. If you want to do nothing when the index out of bounds exception, simply catch it and do nothing when the exception occurs
as

try {
//code that throws the excep
}
catch(StringInd exOutOfBoundsEx ception sE) {
//The exception will be ignored
}
Nov 14 '06 #4
loveme
4 New Member
ok....but after exception it could not read next line...I need to read next line.how it will done...
Nov 14 '06 #5
r035198x
13,262 MVP
ok....but after exception it could not read next line...I need to read next line.how it will done...
Why don't you post the part that throws this exception then. Or better still, just post the whole class
Nov 14 '06 #6

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

Similar topics

7
10850
by: Scott Brady Drummonds | last post by:
Hi, everyone, I'm a Python novice and would love some tips on how I should perform the following task: I'd like to have my Python script read objects (using their constructors) and terminate gracefully when an EOF is encountered. My first attempt looked like this: # This is enclosed in a 'try' block file = open(...) while 1:
0
3504
by: David | last post by:
I've written a small windows service, and I'm having a problem that I'm spending a lot more time on than I'd like. If anyone has experienced this problem and has any hints or solutions; they would be appreciated. Simply leaving the threadMain() method if something unexpected occurs during thread execution leaves the thread in a ThreadState.Running state. This (apparently??) causes the Thread.Join() in service.OnStop() to hang...
2
2632
by: Raghu R | last post by:
From: "R. Raghuraman" <raghuraman@infosys.com> Subject: Problem with XMLValidatingReader? Date: 01 April 2004 11:46 Hi, I have a large xml file to process (~ 70 mb). I am trying to use XMLValidating reader. The first step was to try out the example in quickstart samples with minor modifications . My intention is to validate the file against a DTD before processing and to collect all validation errors in a single pass.
2
2503
by: Sabin Finateanu | last post by:
Hi I'm having problem reading a file from my program and I think it's from a procedure I'm using but I don't see where I'm going wrong. Here is the code: public bool AllowUsage() { OperatingSystem os = Environment.OSVersion; AppDomain ad = Thread.GetDomain();
9
35328
by: haibhoang | last post by:
I have a Windows Service that is trying to parse a large (> 1Gig) text file. I am keep getting OutOfMemoryException exception. Here is the code that's having problem: using (StreamReader streamReader = new StreamReader(stream, Encoding.ASCII)) { string line = ""; DateTime currentDate = DateTime.Now.Date; while (streamReader.Peek() > -1)
7
2326
by: Nathan Sokalski | last post by:
I am having a problem saving an image with the same name it originally had. I have two similar versions of my code, one in which I close the FileStream used to open the original image before saving, the other in which I close the FileStream afterwards, although both return the same error. Here are the two versions of the code and the errors they each return (NOTE: I rebooted immediately before running each of these versions so that I knew they...
2
2970
by: DC | last post by:
The Code <%@ import namespace="System" %> <%@ import namespace="System.Web" %> <%@ import namespace="System.Web.UI" %> <%@ import namespace="System.Web.UI.HtmlControls" %> <%@ import namespace="System.Web.UI.WebControls" %> <%@ import namespace="System.Data" %> <%@ import namespace="System.Data.OleDb" %>
6
8210
by: S Wheeler | last post by:
I have a REALLY nasty problem and could use some expert help. I have two mixed mode apps. Each uses a mixed mode DLL that exports a couple of classes. There is no dll main as it is not needed. This was working fine until a couple of days ago when I added some (a lot of) new code to the dll. The apps generally do not run at the same time. Every thing compiles and links OK. But at run time I now immediately get : The application failed...
20
3029
by: dav3 | last post by:
Alright folks I am in need of a lil guidance/assistance here. I have a program which reads in a txt file. This txt file contains lines of the form January 3, 2007, 85.8 Now each line of the txt file is to be read into my java program and then inserted (from the program into an Access Database). I am not exactly sure of where the problem lies. I know it has something to do with how I am parsing the file, or how I am passing my arguments to...
0
9961
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
11182
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10886
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9597
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
7990
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
7148
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
5824
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
4642
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
4245
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.