The Artima Developer Community
Sponsored Link

Java Answers Forum
parsing

2 replies on 1 page. Most recent reply: Jan 29, 2003 8:52 AM by harihar

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
harihar

Posts: 2
Nickname: harihar
Registered: Jan, 2003

parsing Posted: Jan 28, 2003 8:34 AM
Reply to this message Reply
Advertisement
I am a java newbie. I am trying to create a java program which will read a .txt file. separate individual words and put comma(,) between words.

How can I do this?


Mike Penner

Posts: 16
Nickname: mikepenner
Registered: Jan, 2003

Re: parsing Posted: Jan 28, 2003 10:58 AM
Reply to this message Reply
The java.io.BufferedReader class is good for reading lines from a text file. (Given a file name, I usually use something like new BufferedReader(new FileReader(filename)) to get a BufferedReader from a String containing a file name. I then use BufferedReader's readLine method to get Strings corresponding to lines in the file until that method returns a null.)

The java.util.StringTokenizer class is good for breaking up Strings based on some delimiter(s).

You can find full docs on these classes and more at http://java.sun.com/j2se/1.4.1/docs/api/

harihar

Posts: 2
Nickname: harihar
Registered: Jan, 2003

Re: parsing Posted: Jan 29, 2003 8:52 AM
Reply to this message Reply
Thanks Mike,

I'll look into that.

-Harihar

Flat View: This topic has 2 replies on 1 page
Topic: need help with classes Previous Topic   Next Topic Topic: Simple println command question

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use