Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 19th, 2005, 11:38 PM   #1
squishiful
Programmer
 
Join Date: Jun 2005
Location: Amittyville
Posts: 60
Rep Power: 4 squishiful is on a distinguished road
Read a txt file one word at a time

Is there anyway that I can read a txt file one word at a time? Thanx!
squishiful is offline   Reply With Quote
Old Jun 20th, 2005, 12:03 AM   #2
xavier
Professional Programmer
 
xavier's Avatar
 
Join Date: Oct 2004
Location: .ro
Posts: 406
Rep Power: 5 xavier is on a distinguished road
Send a message via Yahoo to xavier
Well, you could use readLine() from BufferedReader(), so you will read the file line by line
Then you can use StringTokenizer() to split every line into words. Try searching google for those and i think u'll make it.
__________________
Don't take life too seriously, it's not permanent !
xavier is offline   Reply With Quote
Old Jun 20th, 2005, 8:52 AM   #3
skuinders
Hobbyist Programmer
 
skuinders's Avatar
 
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4 skuinders is on a distinguished road
check out the Scanner class (assuming you are using 1.5)

http://java.sun.com/j2se/1.5.0/docs/...l/Scanner.html
__________________
"A stupid man's report of what a clever man says can never be accurate, because he unconciously translates what he hears into something he can understand."
- B. Russell

http://web.bryant.edu/~srk2
skuinders is offline   Reply With Quote
Old Jun 20th, 2005, 9:48 AM   #4
HastaSiempre
Newbie
 
HastaSiempre's Avatar
 
Join Date: Jun 2005
Location: Istanbul University
Posts: 2
Rep Power: 0 HastaSiempre is on a distinguished road
Send a message via MSN to HastaSiempre
Quote:
Originally Posted by squishiful
Is there anyway that I can read a txt file one word at a time? Thanx!
do u wanna count word number of that txt file?
__________________
Religions come and go,but beer and wine always remains with us
HastaSiempre is offline   Reply With Quote
Old Jun 20th, 2005, 10:25 AM   #5
rsnd
Hobbyist Programmer
 
rsnd's Avatar
 
Join Date: Jun 2005
Location: Helltown
Posts: 162
Rep Power: 4 rsnd is on a distinguished road
Try scanner.nextString or something
or use bytebuffers
rsnd is offline   Reply With Quote
Old Jun 20th, 2005, 10:26 AM   #6
Dizzutch
Professional Programmer
 
Dizzutch's Avatar
 
Join Date: Dec 2004
Location: Worcester, MA
Posts: 441
Rep Power: 4 Dizzutch is on a distinguished road
Send a message via ICQ to Dizzutch Send a message via AIM to Dizzutch Send a message via MSN to Dizzutch Send a message via Yahoo to Dizzutch
there is also the StringTokenizer class, worth looking into

-Dizz
__________________
naked pictures of you | PFO F@H stats
Dizzutch is offline   Reply With Quote
Old Jun 20th, 2005, 11:05 AM   #7
Berto
Programming Guru
 
Join Date: Aug 2004
Posts: 1,022
Rep Power: 6 Berto is on a distinguished road
Send a message via AIM to Berto Send a message via MSN to Berto
i always use the string tokenizer.
__________________
"Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute. THAT'S relativity."

- Albert Einstein
Berto is offline   Reply With Quote
Old Jun 22nd, 2005, 12:59 PM   #8
squishiful
Programmer
 
Join Date: Jun 2005
Location: Amittyville
Posts: 60
Rep Power: 4 squishiful is on a distinguished road
thanx!
squishiful is offline   Reply With Quote
Old Jun 24th, 2005, 2:40 PM   #9
squishiful
Programmer
 
Join Date: Jun 2005
Location: Amittyville
Posts: 60
Rep Power: 4 squishiful is on a distinguished road
How about writing to a text file, what should I use for that?
__________________
I steal hippos...
squishiful is offline   Reply With Quote
Old Jun 24th, 2005, 2:46 PM   #10
skuinders
Hobbyist Programmer
 
skuinders's Avatar
 
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4 skuinders is on a distinguished road
Quote:
Originally Posted by squishiful
How about writing to a text file, what should I use for that?
check out the FileOutputStream and PrintWriter classes
__________________
"A stupid man's report of what a clever man says can never be accurate, because he unconciously translates what he hears into something he can understand."
- B. Russell

http://web.bryant.edu/~srk2
skuinders is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:53 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC