Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Chat Program in Java  RSS feed

 
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!