KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > bull > eclipse > jonas > utils > StringUtil


1 package com.bull.eclipse.jonas.utils;
2
3 /*
4  * (c) Copyright Bull SA 2003.
5  * All Rights Reserved.
6  */

7  
8 import java.util.ArrayList JavaDoc;
9 import java.util.StringTokenizer JavaDoc;
10
11 public class StringUtil {
12
13     /**
14      * Concat two arrays of Strings,
15      * part2 is appended to part1
16      */

17     public static String JavaDoc[] concat(String JavaDoc[] part1, String JavaDoc[] part2) {
18         String JavaDoc[] full = new String JavaDoc[part1.length + part2.length];
19         System.arraycopy(part1, 0, full, 0, part1.length);
20         System.arraycopy(part2, 0, full, part1.length, part2.length);
21         return full;
22     }
23
24     /**
25      * See StringTokenizer for delim parameter format
26      */

27     public static String JavaDoc[] cutString(String JavaDoc str, String JavaDoc delim) {
28         ArrayList JavaDoc strings = new ArrayList JavaDoc();
29         StringTokenizer JavaDoc tokenizer = new StringTokenizer JavaDoc(str, delim);
30         while (tokenizer.hasMoreTokens()) {
31             strings.add(tokenizer.nextToken());
32         }
33         
34         return (String JavaDoc[])strings.toArray(new String JavaDoc[0]);
35     }
36
37 }
38
Popular Tags