> one more i wanna ask like how i can write output in different directories > according to key values.
It would be good to know your use case, but maybe you can partition your results according to the keys http://developer.yahoo.com/hadoop/tutorial/module5.html#partitioning and use a customised OutputFormat to put the partitions into different directories http://wiki.apache.org/hadoop/FAQ#How_do_I_change_final_output_file_name_with_the_desired_name_rather_than_in_partitions_like_part-00000.2C_part-00001.3F