Forums Register Login

counting

+Pie Number of slices to send: Send
I'm new to java.
Please help me with these two questions:
1. How to count no of words in a file.
2. How to list all the files present in an particular directory.
+Pie Number of slices to send: Send
Welcome to the JavaRanch, cool sandy. We are a friendly bunch here, so we ask that you use your real name. As our Naming Policy states, accounts with obviously fictitious names will be closed.
You can change your displayed name here.
Thanks.
The questions you are asking are pretty basic. Since there's a chance you may be working on homework, I'm going to steer you in the right direction, but leave the work up to you.
For your first question, in order to count the number of words in a file, first you have to read the file. The Java Tutorial has a chapter on Input/Output. Give it a read.
For your second question, the file system in Java is represented by the java.io.File object.
Give your tasks a try and we'll be here if you have any more questions.
BTW, it's "Heaven doesn't want me. Hell's afraid I'll take over"
+Pie Number of slices to send: Send
Once you've changed your display name, you will face the problem of defining what a word is. Brca1 is the name of a cancer related gene. Would you call it a word? How about 1,2,3-Propanetriol, is it a word? And don't forget to think about '90%' or $321.12. Are these words?

Good luck
Would you like to try a free sample? Today we are featuring tiny ads:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 620 times.
Similar Threads
Ant and Cactus - classpath issues
thanks!!! another SCJP born~
Clock problem
Args in Netbeans
http-method not specified
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 19, 2024 02:50:33.