| | |
# of lines in a text file
![]() |
>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).
Java Syntax (Toggle Plain Text)
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.
![]() |
Similar Threads
- 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
| Thread Tools | Search this Thread |
account android api applet application array arrays automation bidirectional binary birt bluetooth class classes client code columns component constructor database designadrawingapplicationusingjavajslider draw eclipse error errors exception expand fractal game givemetehcodez graphics gui guidancer homework html ide image inetaddress inheritance integer intellij j2me java javamicroeditionuseofmotionsensor javaprojects jlabel jme jni jpanel jtextfield jtree julia linux list loop map method methods midlethttpconnection mobile mobiledevelopmentcreatejar monitoring myaggfun netbeans newbie nullpointerexception open-source oracle plazmic print problem program project property recursion ria scanner search server set sharepoint smart sms smsspam sort sourcelabs splash sql sqlite static string subclass support swing testautomation threads tree unlimited webservices windows






