Here you can find the source of removeKeyPrefix(Properties properties, String prefix)
Parameter | Description |
---|---|
properties | target properties |
prefix | target prefix |
Parameter | Description |
---|---|
IllegalArgumentException | if any parameter is null |
public static void removeKeyPrefix(Properties properties, String prefix)
//package com.java2s; /**//from ww w . j av a2 s . c om * Copyright 2011-2017 Asakusa Framework Team. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.util.Iterator; import java.util.Properties; public class Main { /** * Removes entries which have the specified prefix in their key. * @param properties target properties * @param prefix target prefix * @throws IllegalArgumentException if any parameter is {@code null} */ public static void removeKeyPrefix(Properties properties, String prefix) { if (properties == null) { throw new IllegalArgumentException("properties must not be null"); //$NON-NLS-1$ } if (prefix == null) { throw new IllegalArgumentException("prefix must not be null"); //$NON-NLS-1$ } for (Iterator<?> iter = properties.keySet().iterator(); iter.hasNext();) { Object key = iter.next(); if ((key instanceof String) == false) { continue; } String name = (String) key; if (name.startsWith(prefix)) { iter.remove(); } } } }