The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

Re: skipping counting of comments (lines)

Can you give us an SSCCE that demonstrates an example of the String you're reading in. We don't have the file, so just hardcoding it into a String variable is fine. Also we don't need any of the extra counting logic, just the true or false of whether the String starts with and ends with those characters.

Re: skipping counting of comments (lines)

Originally Posted by KevinWorkman

Can you give us an SSCCE that demonstrates an example of the String you're reading in. We don't have the file, so just hardcoding it into a String variable is fine. Also we don't need any of the extra counting logic, just the true or false of whether the String starts with and ends with those characters.

Thank you so much dear for your quick reply. I dont know what is SSCCE but here are some of my work:

I am using Eclipse software.

I am trying to read a file naming "Dataset.txt". The Dataset.txt contains the following Code lines.

Re: skipping counting of comments (lines)

I linked to the page on an SSCCE- basically, debugging starts with boiling your problem down to a single issue. You have quite a few things going on in your program, so it's hard to figure out which part of that is the actual issue.

For example, does your loop through the lines work? If so, then you can take that out of the SSCCE and simply use a single hardcoded String value. Which part of the if statement is giving you trouble? Test them one at a time to figure it out. If all of them work, perhaps the problem is with your arithmetic somewhere.

When you get it boiled down to an SSCCE of only a few lines, then we can help with your misunderstanding.

Re: skipping counting of comments (lines)

I don't know what you're saying. An SSCCE is simply a smaller version of your program. You have a lot of extra stuff in there, all I'm asking is for you to eliminate that so we can focus on one thing at a time. You've boiled it down to one line, now it becomes your job to put together a sample program showing how that line doesn't work. Which part of that line doesn't work, since there are several pieces working together? What is the input that doesn't work- hard code it.

I predict that one of your assumptions about what the line starts with, ends with, or matches is not valid. The best way to do that is to make a small program that really examines what's going on.

Re: skipping counting of comments (lines)

Originally Posted by KevinWorkman

I don't know what you're saying. An SSCCE is simply a smaller version of your program. You have a lot of extra stuff in there, all I'm asking is for you to eliminate that so we can focus on one thing at a time. You've boiled it down to one line, now it becomes your job to put together a sample program showing how that line doesn't work. Which part of that line doesn't work, since there are several pieces working together? What is the input that doesn't work- hard code it.

I predict that one of your assumptions about what the line starts with, ends with, or matches is not valid. The best way to do that is to make a small program that really examines what's going on.