| Author |
Finding poistion (Line Number) of text in a given File.
|
Sneha Teck
Greenhorn
Joined: Mar 20, 2007
Posts: 7
|
|
Hi,
I have to find the Line Number of a 'text' from within a given file.
The file name and the 'text' is available.
Appreciate any help in achieving this .
Thanks.
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12929
|
|
Here are some pointers:
Example: Read a text file line by lineYou might want to use class java.io.LineNumberReader (lookup the API documentation)There are methods in class String to find out if a string contains a certain text (lookup the API documentation)
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
Monika Joshi
Greenhorn
Joined: Apr 19, 2010
Posts: 9
|
|
Hi,
Here is the pseudocode. This should work.
[Jesper Young: solution deleted]
Regards,
Minakshi
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12929
|
|
Minakshi, welcome to JavaRanch.
I deleted your solution, because on JavaRanch we have a policy that we want to encourage people to learn - giving people complete solutions to their programming assignments does not help people learn. So, thank you for your contribution, but please don't post complete solutions. (And a tip: UseCodeTags when you post source code).
|
 |
 |
|
|
subject: Finding poistion (Line Number) of text in a given File.
|
|
|