Maybe the editiontoCreate string is not in the array. An extra space can go unnoticed and cause problems, especially if dealing with text files.
Main Topics
Browse All Topicshi guys
List editionsToAdd = new ArrayList();
for (int i = 0; i < listFromFiles.size(); i++)
{
editionsToAdd.add(listFrom
}
String editiontoCreate = (String) itemIdandEdtionIdinFTP.get
if (itemIdandEditionIdinDB.co
{
editionsToAdd.remove(editi
System.out.println("Names in editionsToAdd"+editionsToA
}
//editiontoCreate contains abc,def,xyz,eee
// itemIdandEditionIdinDB contains abc,def,xyz
//editionsToAdd also contains abc,def,xyz,eee
the above if condition is getting satisfied, but editionsToAdd.size() is not decreasing
for instance , the first time when itemIdandEditionIdinDB and editiontoCreate are both abc,
i am removing abc from editionsToAdd, but still System.out.println("Names in editionsToAdd"+editionsToA
prints 4 .
any ideas?
thanks
J
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
add some debug - check if editionstoAdd contains the string you're trying to remove
I bet the strings are different.
Sorry about the sloppy indenting.
if (itemIdandEditionIdinDB.co
{
if(editionsToAdd.contains(
System.out.println("editio
editionsToAdd.remove(editi
}else{
System.out.println("editio
}
System.out.println("Names in editionsToAdd"+editionsToA
}
ok, i put a for loop for the remove statement , still no luck
if (itemIdandEditionIdinDB.co
{
for(int h=0;h<editionsToAdd.size()
{
//Remove the editions with same ItemId and EditionId so that editionsToAdd contains only the brand new report editions
editionsToAdd.remove(editi
System.out.println("Names in editionsToAdd"+editionsToA
}
}
not sure where you're going with this CEHJ
He's doing this:
editionsToAdd.remove(editi
System.out.println("Names in editionsToAdd"+editionsToA
He's trying to remove an object from the ArrayList and then check its size.
He's expecting an object to be removed and its not (most likely 'cause the string isn't in the arraylist)
Nothing to do with what's in a loop or editionsToAdd.size() being called
Maybe I'm missing something . . .
iterating and substringing - not checked for syntax or anything.
most likely "mySearchString" will be populated for you in your parent loop.
String mySearchString = "RIINF0010-8092-03-06";
for(int i=0; i < someArrayList.size(); i++){
String currentString = someArrayList.get(i);
//if the search string is found
if (currentString.subString(m
someArrayList.remove(i);
}
}
String mySearchString = "RIINF0010-8092-03-06";
for(int i=0; i < someArrayList.size(); i++){
String currentString = someArrayList.get(i);
//if the search string is found
if (currentString.subString(m
someArrayList.remove(i);
}
}
i dont think it will work aflat, its not just one string. Let me explain with some sample data.
editionsToAdd contains
RIINF0010-8092-03-06-1.PDF
RIINF0010-8092-03-06-2.PDF
RIINF0010-8092-03-06-3.PDF
RIINF0010-7062-03-06-1.PDF
RIINF0010-7062-03-06-2.PDF
RIINF0010-7062-03-06-3.PDF
RIINF0010-6062-03-06-3.PDF
..
editionsToAdd is generated dynamically
editiontoCreate (also generated dynamically) contains
RIINF0010-8092-03-06
RIINF0010-7062-03-06
..more
Now since "part of editionsToAdd" and "editiontoCreate" is exactly the same , i want to delete all common entries from editionsToAdd
so i want to delete
RIINF0010-8092-03-06-1.PDF
RIINF0010-8092-03-06-2.PDF
RIINF0010-8092-03-06-3.PDF
RIINF0010-7062-03-06-1.PDF
RIINF0010-7062-03-06-2.PDF
RIINF0010-7062-03-06-3.PDF
from editionsToAdd so that editionsToAdd is just left with RIINF0010-6062-03-06-3.PDF
The above data is just sample, editionsToAdd would actually contain lots and lots of names.
any ideas greatly appreciated
thanks
J
Business Accounts
Answer for Membership
by: CEHJPosted on 2006-10-10 at 10:59:00ID: 17700772
>>editionsToAdd.add(listFr omFiles.ge t(i));
is in a loop. Nothing else is