Do not use StringTokenizer , it is a legacy class, to quote the javadocs :-
StringTokenizer is a legacy class that is retained for compatibility reasons although its use is discouraged in new code. It is recommended that anyone seeking this functionality use the split method of String or the java.util.regex package instead.
So as recommended use the split() method of the String class instead.
Also as far as deleting content from a file is concerned, you have two options.
In the first, you will need to copy all the content from the first file into a String (or StringBuffer) do all the modifications as necessary to this String, write this new content to a temporary file, delete the original file and then rename the temporary file with the name of the original file.
In the second method you can use the RandomAccessFile class, but I have been told, if you are not careful it can get messy.
stephen84s
Nearly a Posting Virtuoso
1,444 posts since Jul 2007
Reputation Points: 668
Solved Threads: 156
Skill Endorsements: 10
ThankYou so much!!!I thinki will put a delimiter after evry msg For eg.a "$" and then use the temoprary file concept.
No need to actually put a "$" after every message, you could simply put every message on a new line in the file and then split on "\n". for ex:-
This is message1
This is message2
.
.
.
and so on.
Note:-
Please drop the Instant Messaging / SMS speak eg (evry, msg), it is not exactly pleasing to the eyes to read it.
stephen84s
Nearly a Posting Virtuoso
1,444 posts since Jul 2007
Reputation Points: 668
Solved Threads: 156
Skill Endorsements: 10
use scanner it might help you.
rushikesh jadha
Junior Poster in Training
89 posts since Dec 2011
Reputation Points: 4
Solved Threads: 11
Skill Endorsements: 0
use scanner it might help you.
seriously? trying to solve a thread that was solved (since the "Thank you very much" from the OP) about 3 years ago??
stultuske
Industrious Poster
4,382 posts since Jan 2007
Reputation Points: 1,318
Solved Threads: 610
Skill Endorsements: 24