Here you can find the source of getStrings(Properties props, String key, String sep)
Parameter | Description |
---|---|
props | The properties |
key | The key |
sep | The words separator |
public static String[] getStrings(Properties props, String key, String sep)
//package com.java2s; /*/*from ww w . ja v a2s . co m*/ * Copyright 2012 Fabio Strozzi * * 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.ArrayList; import java.util.Properties; import java.util.Scanner; public class Main { /** * Gets an array of string properties given a key and a proper word separator. * * @param props * The properties * @param key * The key * @param sep * The words separator * @return An array of string properties */ public static String[] getStrings(Properties props, String key, String sep) { String val = props.getProperty(key); if (val == null || val.trim().equals("")) return new String[0]; ArrayList<String> l = new ArrayList<String>(5); Scanner s = new Scanner(val); s.useDelimiter(sep); while (s.hasNext()) { String v = s.next(); if (v != null && !v.trim().equals("")) l.add(v.trim()); } return l.toArray(new String[0]); } }