foreach-loop-container

Java, Using Iterator to search an ArrayList and delete matching objects

依然范特西╮ 提交于 2019-11-27 23:11:20
Basically, the user submits a String which the Iterator searches an ArrayList for. When found the Iterator will delete the object containing the String. Because each of these objects contain two Strings, I am finding trouble writing these lines as one. Friend current = it.next(); String currently = current.getFriendCaption(); Thanks for any help! You don't need them on one line, just use remove to remove an item when it matches: Iterator<Friend> it = list.iterator(); while (it.hasNext()) { if (it.next().getFriendCaption().equals(targetCaption)) { it.remove(); // If you know it's unique, you

rename-item and override if filename exists

余生长醉 提交于 2019-11-26 23:26:25
问题 I am trying to use the Rename-Item cmdlet to do the following: I have folder which contains " *.txt " files. Let's say 1.txt, 2.txt etc... I want to copy files that have some prefix, rename them to *.txt and override any existing files if there are any. example: folder: c:\TEST files : 1.txt, 2.txt, 3.txt, 4.txt, 5.txt, index.1.txt, index.2.txt, index.3.txt, index.4.txt, index.5.txt I want to use rename-item to filter any index.*.txt and rename them to *.txt , and if the same file exists,

How do I programmatically get the list of MS Access tables within an SSIS package?

一世执手 提交于 2019-11-26 21:36:26
问题 I have inherited a terribly written MS Access database that I need to import into SQL. The Access database has several thousand tables in it with field definitions that are identical. I have some experience with SSIS, and importing one table is pretty simple. However, I need to create a process where I can loop through the list of several thousand table names and import each table. I found this statement, that will get a list of all the table names in an Access database: SELECT Name FROM

Java, Using Iterator to search an ArrayList and delete matching objects

元气小坏坏 提交于 2019-11-26 21:21:54
问题 Basically, the user submits a String which the Iterator searches an ArrayList for. When found the Iterator will delete the object containing the String. Because each of these objects contain two Strings, I am finding trouble writing these lines as one. Friend current = it.next(); String currently = current.getFriendCaption(); Thanks for any help! 回答1: You don't need them on one line, just use remove to remove an item when it matches: Iterator<Friend> it = list.iterator(); while (it.hasNext())