• Post Reply Bookmark Topic Watch Topic
  • New Topic

Chat Program in Java

 
Raajesh Chandran
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm doing chat program in java.I created the txt file and stored all the users name in that using random acces file.Now I want to sort all the usernames before retriving that one from that file.Is there is any simplest method to do this.While I'm doing this it is getting slow.Since I'm reading the usernames one by one and sort it and then retiving again one by one.
Help me Guys!
 
Faisal Farooqui
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use BufferedReader to make it fast.
I'll suggest u to read all the data in the file in the 1 time. and then perform sorting and then rewrite the whole file by writing the sorted data.
I think it should do
===
FAF
 
Faisal Farooqui
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use BufferedReader to make it fast.
I'll suggest u to read all the data in the file in the 1 time. and then perform sorting and then rewrite the whole file by writing the sorted data.
I think it should do
===
FAF
 
Sarath Mohan
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The above reply is right.
Read all names into TreeSet. object which will automatially sort the names in ascendig order.
Cheers
Binu
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!