•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 391,998 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,201 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 1706 | Replies: 3
![]() |
>I was wondering if there was a way to find how many lines there are in a text file...
http://forum.java.sun.com/thread.jsp...sageID=2200710
However, speed might not be an issue here.
>so can you find out how many lines in the text file start with a particular word (an identifier).
For more advanced work with strings check out the Stringbuffer api.
http://forum.java.sun.com/thread.jsp...sageID=2200710
However, speed might not be an issue here.
>so can you find out how many lines in the text file start with a particular word (an identifier).
class indexTest
{
public static void main (String args[])
{
String str = "This string will be searched";
String find = "will";
System.out.println (str.indexOf ('s')); // find char, no offset
System.out.println (str.lastIndexOf ('s', 4)); // find s, offset by 9
System.out.println (str.indexOf (find)); // find the string find, no offset
System.out.println (str.lastIndexOf(find)); // find the string find in str, no offset
}
}For more advanced work with strings check out the Stringbuffer api.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Java Marketplace
- Reading through lines of text file sequencially (Shell Scripting)
- how to remove a number of lines from a text file ? (Python)
- Replace text in a file (Shell Scripting)
- how do i read the last line of a text file? (Python)
- help on using StringTokenizer to read and compute multiple lines from text (Java)
- Text File Input and manipulation (C++)
- 10 line text file (Java)
Other Threads in the Java Forum
- Previous Thread: calling a the method
- Next Thread: Copying .class files



Linear Mode