By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,032 Members | 811 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,032 IT Pros & Developers. It's quick & easy.

problem in reading line after exception

P: 4
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.println(fstream);
FileOutputStream fstream1 = new FileOutputStream("C://Documents and Settings/sp0c5899/Desktop/msgtracking.log");
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
DataOutputStream out = new DataOutputStream(fstream1);
BufferedWriter br1 = new BufferedWriter(new OutputStreamWriter(out));
try {

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


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

some condition checking

}
catch (Exception e) {//Catch exception if any
System.err.println("Error: " + e);
e.printStackTrace();



}


} catch (Exception e) {//Catch exception if any
System.err.println("Error: " + e);
}
finally{
continue;
}
}
Nov 14 '06 #1
Share this Question
Share on Google+
5 Replies


10K+
P: 13,264
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.println(fstream);
FileOutputStream fstream1 = new FileOutputStream("C://Documents and Settings/sp0c5899/Desktop/msgtracking.log");
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
DataOutputStream out = new DataOutputStream(fstream1);
BufferedWriter br1 = new BufferedWriter(new OutputStreamWriter(out));
try {

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


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

some condition checking

}
catch (Exception e) {//Catch exception if any
System.err.println("Error: " + e);
e.printStackTrace();



}


} catch (Exception e) {//Catch exception if any
System.err.println("Error: " + e);
}
finally{
continue;
}
}
Post code for the whole class and explain your problem again
Nov 14 '06 #2

P: 4
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

10K+
P: 13,264
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(StringIndexOutOfBoundsException sE) {
//The exception will be ignored
}
Nov 14 '06 #4

P: 4
ok....but after exception it could not read next line...I need to read next line.how it will done...
Nov 14 '06 #5

10K+
P: 13,264
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

Post your reply

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