boolean (String current, final Iterator<String> remaining) { if ("-encoding".equalsIgnoreCase(current) && remaining.hasNext()) { final String encoding = remaining.next(); myEncodingName = encoding; return super.handleOption(current, new Iterator<String>() { private boolean encodingConsumed = false; @Override public boolean hasNext() { return !encodingConsumed || remaining.hasNext(); } @Override public String next() { if (!encodingConsumed) { encodingConsumed = true; return encoding; } return remaining.next(); } @Override public void remove() { if (encodingConsumed) { remaining.remove(); } } }); } return super.handleOption(current, remaining); }