45.
String reStr =
""
;
46.
if
(str ==
null
)
47.
return
""
;
48.
char
[] tempChar = str.toCharArray();
49.
for
(
int
kk =
0
; (kk < tempChar.length && toCount > reInt); kk+
+) ...{
50. String s1 = str.valueOf(tempChar[kk]);
51.
byte
[] b = s1.getBytes();
52. reInt += b.length;
53. reStr += tempChar[kk];
54. }
55.
if
(toCount == reInt || (toCount == reInt -
1
))
56. reStr += more;
57.
return
reStr;
58. }
59.
60. =================
61.
62.
/**
63.
* 取字符串的前 toCount 个字符
64.
*
65.
* @param str 被处理字符串
66.
* @param toCount 截取长度
67.
* @param more 后缀字符串
68.
* @version 2004.11.24
69.
* @author zhulx
70.
* @return String
71.
*/
72.
public
static
String substring(String str,
int
toCount,String mor
e)
73. {
74.
int
reInt =
0
;
75.
String reStr =
""
;
76.
if
(str ==
null
)
77.
return
""
;
78.
char
[] tempChar = str.toCharArray();
79.
for
(
int
kk =
0
; (kk < tempChar.length && toCount > reInt); kk+
+) {
80. String s1 = str.valueOf(tempChar[kk]);
81.
byte
[] b = s1.getBytes();
82. reInt += b.length;
83. reStr += tempChar[kk];
84. }
85.
if
(toCount == reInt || (toCount == reInt -
1
))