Here you can find the source of tokenize(final String aInput, final String aDelimiters)
Parameter | Description |
---|---|
aInput | the input string to tokenize, can be <code>null</code>; |
aDelimiters | the delimiter <em>characters</em> to break the given input on, cannot be <code>null</code>. |
null
if the original input was null
.
public static String[] tokenize(final String aInput, final String aDelimiters)
//package com.java2s; /*/* w w w . j a v a 2 s .co m*/ * OpenBench LogicSniffer / SUMP project * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110, USA * * * Copyright (C) 2010-2011 J.W. Janssen, www.lxtreme.nl */ import java.util.*; public class Main { /** * Tokenizes a given input stream and breaks it into parts on the given * delimiters. * * @param aInput * the input string to tokenize, can be <code>null</code>; * @param aDelimiters * the delimiter <em>characters</em> to break the given input on, * cannot be <code>null</code>. * @return the individual tokens of the given input, or <code>null</code> if * the original input was <code>null</code>. */ public static String[] tokenize(final String aInput, final String aDelimiters) { if (aInput == null) { return null; } final List<String> result = new ArrayList<String>(); final StringTokenizer tokenizer = new StringTokenizer(aInput, aDelimiters, false /* returnDelims */); while (tokenizer.hasMoreTokens()) { String token = tokenizer.nextToken(); result.add(token.trim()); } return result.toArray(new String[result.size()]); } }