Find knowledge base article(s) by searching for keywords in the title e.g. type linux in the search box below
Find knowledge base article(s) by browsing the subject categories of articles
Technology quick references, cheatsheets, user manuals etc.
Shop Online through ShopifyLite
Tutorials on various IT applications.
Search Title    (UL:0 |SS:f)

Software >> Development >> Languages >> Java >> Examples >> How to split a string

/* * Uses split to break up a string of input separated by * commas and/or whitespace. */ import java.util.regex.*; public class RegexSplit { public static void main(String[] args) throws Exception { // Create a pattern to match breaks String buf = "one,two,three"; Pattern p = Pattern.compile("[,]"); System.out.println("Before split = " buf); // Split input with the pattern String[] result = p.split(buf); for (int i=0; i<result.length; i ) System.out.println(result[i]); } }
[ © 2008-2021 myfaqbase.com - A property of WPDC Consulting ]