why it doesn't work normal? please give help

dddddd (007_007)
本文发表在 rolia.net/zh 相约加拿大网上社区枫下论坛
package com.bgi.util;

import java.util.*;


public class Spliter {

public Spliter() {
}
private static String nameOfThisClass = "Spliter";
public final static String DELIMITER = "|";

public static String[] split(String s){
return split(s,DELIMITER);
}

public static String[] split(String s, String delimiter){
checkSource(s);
int delimiterLength;int stringLength = s.length();
if (delimiter == null || (delimiterLength = delimiter.length()) == 0){.
return new String[] {s};
}
int count;
int start;
int end;
char slash = '\\';

// Scan s and count the tokens.
count = 0;
start = 0;
while((end = s.indexOf(delimiter, start)) != -1) {

if (s.charAt(end-1)!=slash){
count++;
start = end + delimiterLength;
} else {
start = end + delimiterLength;
continue;
}}

count++;

String[] result = new String[count];
count = 0;
start = 0;
while((end = s.indexOf(delimiter, start)) != -1) {

if(s.charAt(end-1)!=slash){
result[count] = (s.substring(start, end));
count++;
start = end + delimiterLength;
} else {
start = end + delimiterLength;
continue;
}}

end = stringLength;
result[count] = s.substring(start, end);

return (result);
}

/**
* Check if the input parameter is null
*
* @throws IllegalArgumentException if source is null
*/
private static void checkSource(String source)
throws IllegalArgumentException
{
if ( source == null ){
System.out.println( nameOfThisClass + "The input string is null..");
throw new IllegalArgumentException();
}
}

/**
* Test method
*/
public static void main(String args[]){

try{
String a[]=Spliter.split(args[0]);
int i;
for (i=0; i<a.length; i++ ){
System.out.print(a[i]+"^");
}
}
catch(Exception e){
e.printStackTrace();
}
}

}
更多精彩文章及讨论,请光临枫下论坛. 网址: rolia.net/zh
(#368891@0)
2002-2-14 -05:00

回到话题: Java TEST!!

回到论坛: HOME枫下论坛枫下论坛主坛工作学习IT技术讨论

URL:   
http://www.rolia.net/zh/post.php?f=0&p=368891