![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Jun 2005
Location: Amittyville
Posts: 60
Rep Power: 4
![]() |
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!
|
|
|
|
|
|
#2 |
|
Professional Programmer
|
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 ! |
|
|
|
|
|
#3 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4
![]() |
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 |
|
|
|
|
|
#4 | |
|
Newbie
|
Quote:
__________________
Religions come and go,but beer and wine always remains with us
|
|
|
|
|
|
|
#5 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: Helltown
Posts: 162
Rep Power: 4
![]() |
Try scanner.nextString or something
or use bytebuffers |
|
|
|
|
|
#6 |
|
Professional Programmer
|
there is also the StringTokenizer class, worth looking into
-Dizz |
|
|
|
|
|
#7 |
|
Programming Guru
![]() |
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 |
|
|
|
|
|
#8 |
|
Programmer
Join Date: Jun 2005
Location: Amittyville
Posts: 60
Rep Power: 4
![]() |
thanx!
|
|
|
|
|
|
#9 |
|
Programmer
Join Date: Jun 2005
Location: Amittyville
Posts: 60
Rep Power: 4
![]() |
How about writing to a text file, what should I use for that?
__________________
I steal hippos... |
|
|
|
|
|
#10 | |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4
![]() |
Quote:
__________________
"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 |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|