Results 1 to 3 of 3
Thread: Finding line number
- 11-30-2010, 10:40 PM #1
Member
- Join Date
- Nov 2010
- Posts
- 3
- Rep Power
- 0
Finding line number
Hi
im creating a program in java that will read a text file then report the line number of a letter that it detects
if the line is blank it will ignore it but if the line has the letter it is looking for the program will output the line number
im not sure how to go about this
thanks
- 11-30-2010, 10:49 PM #2
Member
- Join Date
- Nov 2010
- Posts
- 33
- Rep Power
- 0
Create an int variable, call it something like "line_count", initialize it to zero.
Start a loop that will read lines from the text file. Read a line, check if the line is blank, if not blank then increment your variable, "line_count++;".
Check the characters in the line. If you find the character you are looking for then output the line number (line_count).
Shouldn't be too hard to do this.
- 11-30-2010, 11:29 PM #3
Member
- Join Date
- Nov 2010
- Posts
- 3
- Rep Power
- 0
Similar Threads
-
Finding the largest number in an array
By starchildren3317 in forum New To JavaReplies: 14Last Post: 11-03-2010, 06:49 AM -
Finding nth prime number
By dextr in forum New To JavaReplies: 2Last Post: 04-12-2010, 11:42 PM -
Finding a number in array close to another number
By SteroidalPsycho in forum New To JavaReplies: 2Last Post: 02-15-2010, 12:37 AM -
finding length on a number
By thekrazykid in forum New To JavaReplies: 8Last Post: 12-12-2008, 08:07 PM -
Finding the highest number
By jigglywiggly in forum New To JavaReplies: 7Last Post: 11-04-2008, 08:14 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks