diff --git a/src/main/java/com/munjaon/server/queue/config/BodyCommonConfig.java b/src/main/java/com/munjaon/server/queue/config/BodyCommonConfig.java new file mode 100644 index 0000000..32f56f4 --- /dev/null +++ b/src/main/java/com/munjaon/server/queue/config/BodyCommonConfig.java @@ -0,0 +1,46 @@ +package com.munjaon.server.queue.config; + +public final class BodyCommonConfig { + /* 회원 아이디 (Length : 20 / Position : 0) */ + public static final int USERID_BYTE_LENGTH = 20; + public static final int USERID_BYTE_POSITION = 0; + /* 요금제 정보 (Length : 1 / Position : 20) (선불 : P(Prepayment) / 후불 : D(Detered Payment)) */ + public static final int FEETYPE_BYTE_LENGTH = 1; + public static final int FEETYPE_BYTE_POSITION = USERID_BYTE_POSITION + USERID_BYTE_LENGTH; + /* 단가정보 (Length : 10 / Position : 21) */ + public static final int UNITCOST_BYTE_LENGTH = 10; + public static final int UNITCOST_BYTE_POSITION = FEETYPE_BYTE_POSITION + FEETYPE_BYTE_LENGTH; + /* 메시지 그룹 아이디 (문자온 메시지 테이블에서 그룹핑할 메시지ID) (Length : 20 / Position : 31) */ + public static final int MSGGROUPID_BYTE_LENGTH = 20; + public static final int MSGGROUPID_BYTE_POSITION = UNITCOST_BYTE_POSITION + UNITCOST_BYTE_LENGTH; + /* 고객사 메시지 ID 길이 (Length : 20 / Position : 51) */ + public static final int MSGID_BYTE_LENGTH = 20; + public static final int MSGID_BYTE_POSITION = MSGGROUPID_BYTE_POSITION + MSGGROUPID_BYTE_LENGTH; + /* 서비스타입(4:SMS / 6:LMS, MMS / 8:카카오 알림톡 / 9:카카오 친구톡) (Length : 1 / Position : 71) */ + public static final int SERVICETYPE_BYTE_LENGTH = 1; + public static final int SERVICETYPE_BYTE_POSITION = MSGID_BYTE_POSITION + MSGID_BYTE_LENGTH; + /* 결과코드 (Length : 5 / Position : 72) */ + public static final int SENDSTATUS_BYTE_LENGTH = 5; + public static final int SENDSTATUS_BYTE_POSITION = SERVICETYPE_BYTE_POSITION + SERVICETYPE_BYTE_LENGTH; + /* 회신번호 (Length : 12 / Position : 77) */ + public static final int SENDER_BYTE_LENGTH = 12; + public static final int SENDER_BYTE_POSITION = SENDSTATUS_BYTE_POSITION + SENDSTATUS_BYTE_LENGTH; + /* 수신번호 (Length : 12 / Position : 89) */ + public static final int RECEIVER_BYTE_LENGTH = 12; + public static final int RECEIVER_BYTE_POSITION = SENDER_BYTE_POSITION + SENDER_BYTE_LENGTH; + /* 예약시간 (Length : 15 / Position : 101) */ + public static final int RESERVEDT_BYTE_LENGTH = 15; + public static final int RESERVEDT_BYTE_POSITION = RECEIVER_BYTE_POSITION + RECEIVER_BYTE_LENGTH; + /* 요청시간 (Length : 15 / Position : 116) */ + public static final int REQUESTDT_BYTE_LENGTH = 15; + public static final int REQUESTDT_BYTE_POSITION = RESERVEDT_BYTE_POSITION + RESERVEDT_BYTE_LENGTH; + /* 원격접속지 주소 (Length : 25 / Position : 131) */ + public static final int REMOTEIP_BYTE_LENGTH = 25; + public static final int REMOTEIP_BYTE_POSITION = REQUESTDT_BYTE_POSITION + REQUESTDT_BYTE_LENGTH; + /* 에이전트 코드 (Length : 5 / Position : 156) */ + public static final int AGENT_CODE_BYTE_LENGTH = 5; + public static final int AGENT_CODE_BYTE_POSITION = REMOTEIP_BYTE_POSITION + REMOTEIP_BYTE_LENGTH; + + /* Body 전체 길이 */ + public static final int COMMON_SUM_BYTE_LENGTH = USERID_BYTE_LENGTH + FEETYPE_BYTE_LENGTH + UNITCOST_BYTE_LENGTH + MSGGROUPID_BYTE_LENGTH + MSGID_BYTE_LENGTH + SERVICETYPE_BYTE_LENGTH + SENDSTATUS_BYTE_LENGTH + SENDER_BYTE_LENGTH + RECEIVER_BYTE_LENGTH + RESERVEDT_BYTE_LENGTH + REQUESTDT_BYTE_LENGTH + REMOTEIP_BYTE_LENGTH + AGENT_CODE_BYTE_LENGTH; +} diff --git a/src/main/java/com/munjaon/server/queue/config/MediaBodyConfig.java b/src/main/java/com/munjaon/server/queue/config/MediaBodyConfig.java new file mode 100644 index 0000000..6dcca07 --- /dev/null +++ b/src/main/java/com/munjaon/server/queue/config/MediaBodyConfig.java @@ -0,0 +1,25 @@ +package com.munjaon.server.queue.config; + +public final class MediaBodyConfig { + /* 제목 (Length : 60 / Position : 161) */ + public static final int SUBJECT_BYTE_LENGTH = 60; + public static final int SUBJECT_BYTE_POSITION = BodyCommonConfig.AGENT_CODE_BYTE_POSITION + BodyCommonConfig.AGENT_CODE_BYTE_LENGTH; + /* LMS/MMS Message (Length : 2000 / Position : 221) */ + public static final int MEDIA_MSG_BYTE_LENGTH = 2000; + public static final int MEDIA_MSG_BYTE_POSITION = SUBJECT_BYTE_POSITION + SUBJECT_BYTE_LENGTH; + /* 파일카운트 (Length : 1 / Position : 2221) */ + public static final int FILECNT_BYTE_LENGTH = 1; + public static final int FILECNT_BYTE_POSITION = MEDIA_MSG_BYTE_POSITION + MEDIA_MSG_BYTE_LENGTH; + /* 파일명 #1 (Length : 128 / Position : 2222) */ + public static final int FILENAME_ONE_BYTE_LENGTH = 128; + public static final int FILENAME_ONE_BYTE_POSITION = FILECNT_BYTE_POSITION + FILECNT_BYTE_LENGTH; + /* 파일명 #2 (Length : 128 / Position : 2350) */ + public static final int FILENAME_TWO_BYTE_LENGTH = 128; + public static final int FILENAME_TWO_BYTE_POSITION = FILENAME_ONE_BYTE_POSITION + FILENAME_ONE_BYTE_LENGTH; + /* 파일명 #3 (Length : 128 / Position : 2478) */ + public static final int FILENAME_THREE_BYTE_LENGTH = 128; + public static final int FILENAME_THREE_BYTE_POSITION = FILENAME_TWO_BYTE_POSITION + FILENAME_TWO_BYTE_LENGTH; + + /* Media Body 길이 */ + public static final int MEDIA_SUM_BYTE_LENGTH = BodyCommonConfig.COMMON_SUM_BYTE_LENGTH + SUBJECT_BYTE_LENGTH + MEDIA_MSG_BYTE_LENGTH + FILECNT_BYTE_LENGTH + FILENAME_ONE_BYTE_LENGTH + FILENAME_TWO_BYTE_LENGTH + FILENAME_THREE_BYTE_LENGTH; +} diff --git a/src/main/java/com/munjaon/server/queue/config/QueueHeaderConfig.java b/src/main/java/com/munjaon/server/queue/config/QueueHeaderConfig.java index 9ae006c..544cc13 100644 --- a/src/main/java/com/munjaon/server/queue/config/QueueHeaderConfig.java +++ b/src/main/java/com/munjaon/server/queue/config/QueueHeaderConfig.java @@ -1,14 +1,15 @@ package com.munjaon.server.queue.config; public final class QueueHeaderConfig { - /** Queue File Header Length - [Create Date:10 Byte, Push Count:10 Byte] */ - public static final int QUEUE_HEADER_LENGTH = 20; - /* 큐생성일 읽을 위치값 */ + /* 변수 정의 : 전체 길이 : 개별 변수 Length : 개별 변수 Position */ + /* 큐생성일 읽을 위치값 : 0 */ public static final int CREATE_DATE_POSITION = 0; /* 큐생성일 읽을 크기 */ public static final int CREATE_DATE_LENGTH = 10; /* 큐 쓰기 카운트 읽을 위치값 */ - public static final int PUSH_COUNT_POSITION = 10; + public static final int PUSH_COUNT_POSITION = CREATE_DATE_POSITION + CREATE_DATE_LENGTH; /* 큐 쓰기 카운트 읽을 크기 */ public static final int PUSH_COUNT_LENGTH = 10; + /* Queue File Header Length - [Create Date:10 Byte, Push Count:10 Byte] */ + public static final int QUEUE_HEADER_LENGTH = CREATE_DATE_LENGTH + PUSH_COUNT_LENGTH; } diff --git a/src/main/java/com/munjaon/server/queue/config/SmsBodyConfig.java b/src/main/java/com/munjaon/server/queue/config/SmsBodyConfig.java new file mode 100644 index 0000000..c5d52a4 --- /dev/null +++ b/src/main/java/com/munjaon/server/queue/config/SmsBodyConfig.java @@ -0,0 +1,10 @@ +package com.munjaon.server.queue.config; + +public final class SmsBodyConfig { + /* SMS Message (Length : 160 / Position : 161) */ + public static final int SMS_MSG_BYTE_LENGTH = 160; + public static final int SMS_MSG_BYTE_POSITION = BodyCommonConfig.AGENT_CODE_BYTE_POSITION + BodyCommonConfig.AGENT_CODE_BYTE_LENGTH; + + /* SMS Body 길이 */ + public static final int SMS_SUM_BYTE_LENGTH = BodyCommonConfig.COMMON_SUM_BYTE_LENGTH + SMS_MSG_BYTE_LENGTH; +} diff --git a/src/main/java/com/munjaon/server/queue/dto/BasicMessageDto.java b/src/main/java/com/munjaon/server/queue/dto/BasicMessageDto.java index e2e14d8..8df6307 100644 --- a/src/main/java/com/munjaon/server/queue/dto/BasicMessageDto.java +++ b/src/main/java/com/munjaon/server/queue/dto/BasicMessageDto.java @@ -8,11 +8,20 @@ import lombok.ToString; @Setter @ToString public class BasicMessageDto { + protected String userId = ""; + protected String feeType = ""; + protected String unitCost = ""; + protected String msgGroupID = "0"; protected String userMsgID = ""; + protected String serviceType = ""; + protected String sendStatus = "0"; protected String userSender = ""; protected String userReceiver = ""; + protected String reserveDt = ""; + protected String requestDt; + protected String remoteIP = "127.0.0.1"; + protected String routerSeq = "0"; + protected String userMessage = ""; protected String userMsgType = ""; - protected String userRequestDate = ""; - protected String sendStatus = "0"; } diff --git a/src/main/java/com/munjaon/server/util/ByteUtil.java b/src/main/java/com/munjaon/server/util/ByteUtil.java new file mode 100644 index 0000000..35e9b6f --- /dev/null +++ b/src/main/java/com/munjaon/server/util/ByteUtil.java @@ -0,0 +1,423 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package com.munjaon.server.util; + +/** + * bytes 관련 유틸리티 클래스 + * @author JDS + */ +public final class ByteUtil { + public static final int BYTE_SIZE = 128; + /* 큐에 저장하기전에 바이트를 채울 문자 */ + public static final byte SET_DEFAULT_BYTE = (byte) 0x00; + + /** + * bytes 배열의 핵사값을 16자리씩 개행하여 반환한다.
+ * 핵사 로그 출력을 위해 사용한다. + * @param src + * @param isLine + * @return 16자리씩 개행된 핵사값 + */ + public static String byteToHex(byte[] src, boolean isLine) { + String hex = ""; + // if(src.length > 16) + hex = ""; + for (int i = 0, j = 1; i < src.length; i++, j++) { + hex += pad0(Integer.toHexString(src[i] & 0xff), 2) + " "; + + if (isLine && src.length > 16 && (j % 16) == 0) { + // hex += " " + new String(codes, j-16, 16); + hex += "\r\n"; + } + } + return hex; + } + + /** + * bytes 배열의 핵사값을 16자리씩 개행하여 반환한다.
+ * 핵사 로그 출력을 위해 사용한다. + * @param src + * @return 16자리씩 개행된 핵사값 + */ + public static String byteToHex(byte[] src) { + String hex = ""; + // if(src.length > 16) + //hex = "\r\n"; + for (int i = 0, j = 1; i < src.length; i++, j++) { + hex += pad0(Integer.toHexString(src[i] & 0xff), 2) + " "; + + if (src.length > 16 && (j % 16) == 0) { + // hex += " " + new String(codes, j-16, 16); + hex += "\r\n"; + } + } + return hex; + } + + /** + * bytes 배열의 지정된 위치값에 대해 16자리씩 개행된 핵사값으로 반환한다.
+ * 핵사 로그 출력을 위해 사용한다. + * @param src + * @param srcPos + * @param length + * @return 16자리씩 개행된 핵사값 + */ + public static String byteToHex(byte[] src, int srcPos, int length) { + String hex = ""; + //if(src.length > 16) + hex = "\r\n"; + for (int i = srcPos, j = 1; i < srcPos + length; i++, j++) { + hex += pad0(Integer.toHexString(src[i] & 0xff), 2) + " "; + if (src.length > 16 && (j % 16) == 0) { + hex += "\r\n"; + } + } + return hex; + } + + public static String intToHex(int src) { + String hex = "0x"; + byte[] bSrc = ByteUtil.intToByte(src); + for (int i = 0, j = 1; i < bSrc.length; i++, j++) { + hex += pad0(Integer.toHexString(bSrc[i] & 0xff), 2); + } + return hex; + } + + public static byte[] shortToByte(short s) { + byte dest[] = new byte[2]; + dest[1] = (byte) (s & 0xff); + dest[0] = (byte) (s >>> 8 & 0xff); + return dest; + } + + public static byte[] intToByte(int i) { + byte dest[] = new byte[4]; + dest[3] = (byte) (i & 0xff); + dest[2] = (byte) (i >>> 8 & 0xff); + dest[1] = (byte) (i >>> 16 & 0xff); + dest[0] = (byte) (i >>> 24 & 0xff); + return dest; + } + + public static byte[] longToByte(long l) { + byte dest[] = new byte[8]; + dest[7] = (byte) (int) (l & 255L); + dest[6] = (byte) (int) (l >>> 8 & 255L); + dest[5] = (byte) (int) (l >>> 16 & 255L); + dest[4] = (byte) (int) (l >>> 24 & 255L); + dest[3] = (byte) (int) (l >>> 32 & 255L); + dest[2] = (byte) (int) (l >>> 40 & 255L); + dest[1] = (byte) (int) (l >>> 48 & 255L); + dest[0] = (byte) (int) (l >>> 56 & 255L); + return dest; + } + + public static byte[] floatToByte(float f) { + byte dest[] = new byte[4]; + return setFloat(dest, 0, f); + } + + public static byte[] doubleToByte(double d) { + byte dest[] = new byte[8]; + return setDouble(dest, 0, d); + } + + public static byte getByte(byte src[], int offset) { + return src[offset]; + } + + public static byte[] getBytes(String data) { + byte[] b = null; + + b = data.getBytes(); + + return (b); + } + + public static byte[] getBytes(byte src[], int offset, int length) { + byte dest[] = new byte[length]; + System.arraycopy(src, offset, dest, 0, length); + return dest; + } + + public static short getShort(byte src[], int offset) { + return (short) ((src[offset] & 0xff) << 8 | src[offset + 1] & 0xff); + } + + public static int getInt(byte src[], int offset) { + return (src[offset] & 0xff) << 24 | (src[offset + 1] & 0xff) << 16 + | (src[offset + 2] & 0xff) << 8 | src[offset + 3] & 0xff; + } + + public static long getLong(byte src[], int offset) { + return (long) getInt(src, offset) << 32 + | (long) getInt(src, offset + 4) & 0xffffffffL; + } + + public static float getfloat(byte src[], int offset) { + return Float.intBitsToFloat(getInt(src, offset)); + } + + public static double getdouble(byte src[], int offset) { + return Double.longBitsToDouble(getLong(src, offset)); + } + + public static byte[] setByte(byte dest[], int offset, byte b) { + dest[offset] = b; + return dest; + } + + public static void setBytes(byte[] dest, int offset, String s) { + setBytes(dest, offset, s.getBytes()); + } + + public static byte[] setBytes(byte dest[], int offset, byte src[]) { + System.arraycopy(src, 0, dest, offset, src.length); + return dest; + } + + public static byte[] setBytes(byte dest[], int offset, byte src[], + int len) { + System.arraycopy(src, 0, dest, offset, len); + return dest; + } + + public static byte[] setShort(byte dest[], int offset, short s) { + dest[offset] = (byte) (s >>> 8 & 0xff); + dest[offset + 1] = (byte) (s & 0xff); + return dest; + } + + public static byte[] setInt(byte dest[], int offset, int i) { + dest[offset] = (byte) (i >>> 24 & 0xff); + dest[offset + 1] = (byte) (i >>> 16 & 0xff); + dest[offset + 2] = (byte) (i >>> 8 & 0xff); + dest[offset + 3] = (byte) (i & 0xff); + return dest; + } + + public static byte[] setLong(byte dest[], int offset, long l) { + setInt(dest, offset, (int) (l >>> 32)); + setInt(dest, offset + 4, (int) (l & 0xffffffffL)); + return dest; + } + + public static byte[] setFloat(byte dest[], int offset, float f) { + return setInt(dest, offset, Float.floatToIntBits(f)); + } + + public static byte[] setDouble(byte dest[], int offset, double d) { + return setLong(dest, offset, Double.doubleToLongBits(d)); + } + + public static boolean isEquals(byte b[], String s) { + if (b == null || s == null) + return false; + int slen = s.length(); + if (b.length != slen) + return false; + for (int i = slen; i-- > 0;) + if (b[i] != s.charAt(i)) + return false; + + return true; + } + + public static boolean isEquals(byte a[], byte b[]) { + if (a == null || b == null) + return false; + if (a.length != b.length) + return false; + for (int i = a.length; i-- > 0;) + if (a[i] != b[i]) + return false; + + return true; + } + + public static int hexToInt(byte[] b) { + int sum = 0; + int len = 0; + int pos = 0; + + if (b != null) { + len = b.length; + + for (int i = len - 1; i > 0; i--) { + sum += sqrt(BYTE_SIZE, i) * (int) b[pos]; + pos++; + } + sum += b[pos]; + } + + return (sum); + } + + public static int hexToInt(byte[] b, int start, int len) { + int sum = 0; + int pos = start; + + if (b != null) { + for (int i = len - 1; i > 0; i--) { + sum += sqrt(BYTE_SIZE, i) * (int) b[pos]; + pos++; + } + sum += b[pos]; + } + + return (sum); + } + + public static byte[] intToHex(int num, int digit) { + byte[] b = new byte[digit]; + int[] intArr = makeFunction(num, digit, BYTE_SIZE); + + for (int i = 0; i < digit; i++) { + b[i] = (byte) intArr[i]; + } + + return (b); + } + + private static int[] makeFunction(int num, int digit, int jinso) { + int[] fun = new int[digit]; + int restNum = num; + int pos = 0; + + for (int i = digit - 1; i > 0; i--) { + int quotient = restNum / sqrt(jinso, i); + fun[pos++] = quotient; + restNum -= (quotient * sqrt(jinso, i)); + } + fun[pos++] = restNum; + + return (fun); + } + + private static int sqrt(int num, int count) { + int sum = 0; + + sum = (count >= 1) ? num : 0; + for (int i = 1; i < count; i++) { + sum = sum * num; + } + + return (sum); + } + + public static boolean arrayComp(byte[] src, byte[] obj) { + boolean isSame = true; + + if (src.length != obj.length) { + isSame = false; + } else { + for (int i = 0; i < src.length; i++) { + if (src[i] != obj[i]) { + isSame = false; + break; + } + } + } + + return (isSame); + } + + public static String pad0(String str, int size) { + char[] zeros = new char[size - str.length()]; + for (int i = 0; i < zeros.length; i++) + zeros[i] = '0'; + return new String(zeros) + str; + } + + public static byte[] convertCharArrayToByteArray(char[] ca) { + byte[] ba = new byte[ca.length*2]; + java.nio.ByteBuffer.wrap(ba).asCharBuffer().put(ca); + return ba; + } + + public static char[] convertByteArrayToCharArray(byte[] ba) { + char[] ca = new char[ba.length/2]; + java.nio.ByteBuffer.wrap(ba).asCharBuffer().get(ca); + return ca; + } + + public static byte[] setNull(byte[] b) { + for(int i=0; i> 8 & 0xff); + ret[1] = (byte)(value >> 16 & 0xff); + ret[0] = (byte)(value >> 24 & 0xff); + + return ret; + } + + // Little Endian + public static int toInt2(byte[] value) { + return (int)( + (value[0] & 0xff) | + (value[1] & 0xff) << 8 | + (value[2] & 0xff) << 16 | + (value[3] & 0xff) << 24 ); + } + + // Little Endian + public static byte[] toBytes2(int value) { + byte[] ret = new byte[4]; + + ret[0] = (byte)(value & 0xff); + ret[1] = (byte)(value >> 8 & 0xff); + ret[2] = (byte)(value >> 16 & 0xff); + ret[3] = (byte)(value >> 24 & 0xff); + + return ret; + } + + public static byte[] setSpaceAll(byte[] data) { + return setAll(data, (byte) ' '); + } + + public static byte[] setAll(byte[] data, byte bt) { + int len = data.length; + + for( int i=0; i 0){ + headNum = srcNum.substring(0, index); + tailNum = srcNum.substring((index + 1), srcNum.length()); + + if(tailNum.length() == 0){ + tailNum = "0"; + } + if(tailNum.length() > digit){ + tailNum = tailNum.substring(0, digit); + } + retNum = headNum + "." + tailNum; + } + } + + return retNum; + } + + // 수신번호 체크하기 + public static boolean CheckPhone(String src) { + if(src == null || src.trim().length() < 10) { + return false; + } + + if(!src.startsWith("0")) { + return false; + } + + return true; + } + // 문자열 공백 제거 + public static String trim(String obj) { + return StringUtil.trim(obj); + } +} diff --git a/src/main/java/com/munjaon/server/util/StringUtil.java b/src/main/java/com/munjaon/server/util/StringUtil.java new file mode 100644 index 0000000..f6d2a89 --- /dev/null +++ b/src/main/java/com/munjaon/server/util/StringUtil.java @@ -0,0 +1,167 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package com.munjaon.server.util; + +import java.text.DecimalFormat; +import java.util.ArrayList; + +/** + * 문자열 관련 유틸리티 클래스 + * @author JDS + */ +public final class StringUtil { + + public static final String SystemEncoding = getSystemEncoding(); + + public static String getSystemEncoding() { + return (new java.io.OutputStreamWriter(System.out)).getEncoding(); + } + + public static String trim(byte[] obj) { + if( obj == null || obj.length == 0 ) { + return ""; + } + + return (new String(obj)).trim(); + } + + public static String trim(Object obj) { + return trim(obj, ""); + } + + public static String trim(Object obj, String dflt) { + if( obj == null ) { + return dflt; + } + + return ((String)obj).trim(); + } + + public static String ltrim(byte[] obj) { + return ltrim(new String(obj)); + } + + public static String ltrim(String obj) { + return ltrim(obj.toCharArray()); + } + + public static String ltrim(char[] obj) { + int len = obj.length; + int idx = 0; + + while( idx < len && obj[idx] <= ' ' ) { + idx++; + } + + return new String(obj, idx, len-idx); + } + + public static String rtrim(byte[] obj) { + return rtrim(new String(obj)); + } + + public static String rtrim(String obj) { + return rtrim(obj.toCharArray()); + } + + public static String rtrim(char[] obj) { + int len = obj.length; + int idx = len-1; + + while( idx >= 0 && obj[idx] <= ' ' ) { + idx--; + } + + return new String(obj, 0, idx+1); + } + + public static String replaceAll(String src, String from, String to) { + StringBuilder sbuf = new StringBuilder(); + + int len = from.length(); + int idx = 0; + int stx = 0; + + while( (idx=src.indexOf(from, stx)) > -1 ) { + sbuf.append(src.substring(stx, idx)); + sbuf.append(to); + stx=idx+len; + } + + sbuf.append(src.substring(stx)); + + return sbuf.toString(); + } + + public static String[] split(String sSrc, String sDelim) { + ArrayList aList = new ArrayList(); + + String sTmp; + int len = sDelim.length(); + int idx = 0; + int stx = 0; + + while( (idx=sSrc.indexOf(sDelim, stx)) > -1 ) { + sTmp = sSrc.substring(stx, idx); + aList.add(sTmp); + stx=idx+len; + } + + if( stx <= sSrc.length() ) { + aList.add(sSrc.substring(stx)); + } + + String[] sRet = new String[aList.size()]; + + for( int i=0; i