A name the first letter of
A name the first letter of
Package com.scs.common.function;
(Public class GetCh2Spell
Public static int compare (String str1, String str2) (
Int result = 0;
String m_s1 = null;
String m_s2 = null;
Try (
M_s1 = new String (str1.getBytes (_FromEncode_), _ToEncode_);
M_s2 = new String (str2.getBytes (_FromEncode_), _ToEncode_);
)
Catch (Exception e) (
Return str1.compareTo (str2);
)
Result = chineseCompareTo (m_s1, m_s2);
Return result;
)
Public static int getCharCode (String s) (
If (s == null & & (s.equals (""))
Return -1;
)
[] Byte b = s.getBytes ();
Int value = 0;
For (int i = 0; i <b.length & & i <= 2; i + +) (
Value = value * 100 + b [i];
)
Return value;
)
Public static int chineseCompareTo (String s1, String s2) (
Int len1 = s1.length ();
Int len2 = s2.length ();
Int n = Math.min (len1, len2);
For (int i = 0; i <n; i + +) (
Int s1_code = getCharCode (s1.charAt (i) + "");
Int s2_code = getCharCode (s2.charAt (i) + "");
If (s1_code * s2_code <0) (
Return Math.min (s1_code, s2_code);
)
If (s1_code! = S2_code) (
Return s1_code - s2_code;
)
)
Return len1 - len2;
)
Public static String getBeginCharacter (String res) (
String a = res;
String result = "";
For (int i = 0; i <a.length (); i + +) (
String current = a.substring (i, i + 1);
If (compare (current, "\ u554A") <0) (
Result = result + current;
)
Else
If (compare (current, "\ u554A")> = 0 & &
Compare (current, "\ u5EA7") <= 0) (
If (compare (current, "\ u531D")> = 0) (
Result = result + "z";
)
Else
If (compare (current, "\ u538B")> = 0) (
+ Result result = "y";
)
Else
If (compare (current, "\ u6614")> = 0) (
+ Result result = "x";
)
Else
If (compare (current, "\ u6316")> = 0) (
Result = result + "w";
)
Else
If (compare (current, "\ u584C")> = 0) (
Result = result + "t";
)
Else
If (compare (current, "\ u6492")> = 0) (
Result = result + "s";
)
Else
If (compare (current, "\ u7136")> = 0) (
Result = result + "r";
)
Else
If (compare (current, "\ u671F")> = 0) (
Result = result + "q";
)
Else
If (compare (current, "\ u556A")> = 0) (
+ Result result = "p";
)
Else
If (compare (current, "\ u54E6")> = 0) (
Result = result + "o";
)
Else
If (compare (current, "\ u62FF")> = 0) (
Result = result + "n";
)
Else
If (compare (current, "\ u5988")> = 0) (
+ Result result = "m";
)
Else
If (compare (current, "\ u5783")> = 0) (
+ Result result = "l";
)
Else
If (compare (current, "\ u5580")> = 0) (
Result = result + "k";
)
Else
If (compare (current, "\ u51FB")> 0) (
Result = result + "j";
)
Else
If (compare (current, "\ u54C8")> = 0) (
+ Result result = "h";
)
Else
If (compare (current, "\ u5676")> = 0) (
Result = result + "g";
)
Else
If (compare (current, "\ u53D1")> = 0) (
Result = result + "f";
)
Else
If (compare (current, "\ u86FE")> = 0) (
Result = result + "e";
)
Else
If (compare (current, "\ u642D")> = 0) (
+ Result result = "d";
)
Else
If (compare (current, "\ u64E6")> = 0) (
+ Result result = "c";
)
Else
If (compare (current, "\ u82AD")> = 0) (
+ Result result = "b";
)
Else
If (compare (current, "\ u554A")> = 0) (
+ Result result = "a";
)
)
)
Return result;
)
Public static String getFirstStr (String str) (
String temp = "";
For (int i = 0; i <str.length (); i + +) (
String sss = "";
Char a = str.charAt (i);
Char aa [] = (
A
);
Sss = new String (aa);
If (Character.isDigit (aa [0])) (
Sss = "data";
)
Else
If (a> = 'a' & & a <= 'z' | | a> = 'A' & & a <= 'Z') (
Sss = "character";
)
Else (
Sss = getBeginCharacter (sss);
)
Temp = temp + sss;
)
Return temp;
)
Private static String _FromEncode_ = "GBK";
Private static String _ToEncode_ = "GBK";
)
Projects in the category






