Here you can find the source of split(String str, String delim)
Parameter | Description |
---|---|
str | String with delimited fields. |
delim | String that represents the delimiter. |
public static String[] split(String str, String delim)
//package com.java2s; /***/*from w w w .j av a 2s . co m*/ * jwma Java WebMail * Copyright (c) 2000-2003 jwma team * * jwma is free software; you can distribute and use this source * under the terms of the BSD-style license received along with * the distribution. ***/ import java.util.*; public class Main { /** * Method that splits a string with delimited fields * into an array of strings. * * @param str String with delimited fields. * @param delim String that represents the delimiter. * * @return the String[] that contains all splitted fields. */ public static String[] split(String str, String delim) { StringTokenizer strtok = new StringTokenizer(str, delim); String[] result = new String[strtok.countTokens()]; for (int i = 0; i < result.length; i++) { result[i] = strtok.nextToken(); } return result; } }