Ok so heres what I need to do. I’ve got a file that contains the Names of Categories and is called “categories.txt” then I have files which are the Names of the categories, e.g “Mail.txt”,”News.txt” etc, and those files contain link names such as “Hotmail” and “BBC News”. Now what i’m looking to do is to count the number of links in each category which I can do by putting the contents of each category into an array and then finding the size of it. But after that I need to display the categories from the one with the most links to the one with the least. I’m not sure how to go about this at all, so any help would be greatly appreciated.
I now have this so far to change the position of the categories in the arraylist depending on the size of the file. However it seems to throw an error at the end of the code after the first change has taken place. Any ideas why?
Iterator itty = parts.iterator();
int i = -1;
int count = 0;
int tempCount = 0;
String tempName = "";
while (itty.hasNext()){
i++;
catName = parts.get(i).toString();
PARTS addMenu = new PARTS("" + catName);
count = addMenu.links().size();
if (i > 0){
if (tempCount < count){
int ind = parts.indexOf(catName);
parts.remove(tempName);
parts.add(ind,tempName);
System.out.print(parts.toString());
}
}
tempCount = count;
tempName = catName;
itty.next();
}
1. Read the categories.txt file , read one category say for example
newsnow try opening news.txt and count the no of records inside the news.txt update map accordingly.2. To hold link for each category use