Here you can find the source of splitString(String data, String delimiter)
Parameter | Description |
---|---|
data | a parameter |
delimiter | a parameter |
public static ArrayList<String> splitString(String data, String delimiter)
//package com.java2s; /**/*from w w w.ja v a 2 s .co m*/ * Copyright 2016 LinkedIn Corp. All rights reserved. * * 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. */ import java.util.ArrayList; import java.util.Arrays; public class Main { /** * Split the input string "data" using the delimiter and return as list of strings for the slices obtained * @param data * @param delimiter * @return */ public static ArrayList<String> splitString(String data, String delimiter) { if (data == null) { throw new IllegalArgumentException("Passed in string is null "); } ArrayList<String> toReturn = new ArrayList<String>(); String[] slices = data.split(delimiter); toReturn.addAll(Arrays.asList(slices)); return toReturn; } }