I wrote the following code and the inner for loop works fine, but the outer loop does not iterate. Here is my code:
BufferedReader userfeatures = new BufferedReader(new FileReader("userFeatureVectorsTest.csv"));
BufferedReader itemfeatures = new BufferedReader(new FileReader("ItemFeatureVectorsTest.csv"));
while ((Uline = userfeatures.readLine()) != null)
{
for (String Iline = itemfeatures.readLine(); Iline != null; Iline = itemfeatures.readLine())
{
System.out.println(intersect(Uline, Iline).size());
System.out.println(union(Uline, Iline).size());
}
}
userfeatures.close();
itemfeatures.close();
}
It finds the intersection and union of the first line of the first file with every line of the 2nd file and then it stops. However, I need to continue and repeat the same procedure for next lines of the first file. So, I think there is some problems related to my outer while loop, but I could not find what is the proble :|
Could someone help me please?
Thanks
itemfeaturesanditemfeatures.readLine()returns null since you are already at the end of the file.itemFeaturesinside the outer loop. Or you could read the contents of the second file once and cache the information you need.