can anyone provide with java code for performing text similarity calculation using cosine similarity. it is a part of my project.. the context is
a pair of records P12 = {r1,r2} , where r1 and r2 can come from same or different data sources, as a similarity vector V12 = <v1,v2,....vn>, in which vi represents the ith field similarity between r1 and r2.vi = 1 means field similarity between r1 and r2 are equal and vi =0 means the ith fields of r1 and r2 are totally different.

so using cosine similarity calculation i require output like that.

can anyone provide with java code for performing text similarity

No, not even a hint until you show us what you tried.