Could someone help java code to read number of lines, words and characrters in paragragh .

Could someone help java code to read number of lines, words and characrters in paragragh .

You can count how may times the \n appears in the paragraph for lines.
For characters the total length of the paragraph String minus the characters: " ", " ", " ", ...
For words user String.split(" "); and count the length of the array minus the elements where you might an empty String with more than one length.

Or you can use regular expressions.

Yes that is a good way to do it. but when you do that you could use StringTokenizer class. it seperates a string to tokens. just change the delimeters to count sentences , lines ,words etc. I hope that could help.

note:
every sencence finish with "."
every line finish with "\n"
every word finish with "\n" , " " , "." or ","

Daniweb member rules include
"Do ensure that all posts contain relevant content and substance and are not simply vehicles for external links"
We also discourage people from simp/ky posting complete solutions.In future please help by pointing people in the right direction.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.