Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Splitting up messages in a text file  RSS feed

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Im working on a basic email filter, which will read in a text file of several hundred email messages, increment a counter for an individual message, tokenise it, count number of occurences of token in that email then store in a dictionary. I have built a couple of classes that do certain things and they work ok. Although i cant figure out how i can split up each individual message in the text file. At the moment i just read the whole text file in, with no method of splitting the text file up into individual messages. The messages in the text file are split by 10 dashes (----------). Here are my classes so far:
Tokeniser.java
Comwords.java (removes common words like 'the', 'a' etc)
Does anyone have any ideas how i might solve this problem?
Thanks
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you just test for a line of ten dashes immediately after the read - the first line inside your loop?

For a real change of direction, if you have JDK 5 look at Scanner. That could probably read one message at a time by using the dashes as a delimiter.

Any chance you'll be bitten by somebody including a line of dashes in their mail message?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!