How to count occurrence of a string in a string array list. I have 800,000 strings in string list..
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
How to count occurrence of a string in a string array list. I have 800,000 strings in string list..
Hi,
Post your full code what you tried.
Happy to help you
thanks,
Now I have one array of strings which has 60,000 unique strings. I also have one string abcd which has comma separated values of substrings. I want to find the occurrences of those unique strings in string abcd.
I have tried like this..
public void getscore () throws FileNotFoundException, IOException{
byte[] buffer = new byte[1028];
BufferedInputStream bufferedInput = new BufferedInputStream(new FileInputStream("F:/Major Project/DataSets/Bibsonomy/2008/modified/modified/titledata3"));
int bytesRead = 0;
while ((bytesRead = bufferedInput.read(buffer)) != -1) {
String chunk = new String(buffer, 0, bytesRead);
String a2[] = chunk.split(",");
for(int i=0;i<a2.length;i++)
abc.add(a2[i]);
String chunk2 = new String(buffer,0,bytesRead);
String a3[] = chunk.split(",");
for(int i=0;i<a3.length;i++){
xyz.add(a3[i]);
}
}
}
public void findcount (){
//abc.toArray(a5);
int n1;
int c = 0;
int i =0;
n1 = abc.size();
// System.out.println(n1);
String abcd = abc.toString();
xyz.toArray(a4);
findStr = a4[1];
System.out.println(a4[1]);
while(!abcd.isEmpty()){
if(a4[1].equalsIgnoreCase(abcd));
{
c++;
}
// i++;
}
System.out.println("Count is " +c);
}
// Thanks for reply..
Welcome to the forum. Please read this topic to learn how to post code correctly.
Please give your threads more useful/meaningful titles.