I need to take a java file as an input to a servlet program and implement LOCcounter() function, to count th LOC of the program, ignoring blankslines and comments. Im not going anywhere, please hlp me
Since we do not hand out ready made code here at the Ranch, I will share some pseudo code with you.
1) Open a stream to the. For this you can either use BufferedReader or Scanner
2) Read one line at a time
3) Increment the counter
4) When you finish reading the file, the counter will tell you the number of lines.
This is basic stuff. You need to build logic for identifying if the read line is empty and if the read line was part of some comment.
You have also failed to take into consideration the package statement and import statements. If you ignore them, your code is going to be flawed.