Java °´×Ö½Ú½ØÈ¡´øÓкº×ÖµÄ×Ö·û´®µÄÒ»ÖÖ×ö·¨
Java °´×Ö½Ú½ØÈ¡´øÓкº×ÖµÄ×Ö·û´®µÄ½â·¨£¬ÍøÉÏÓв»ÉÙÌÖÂÛ¡£ÕâÀïÎÒÒ²¸ø³öÒ»ÖÖÎÒ×Ô¼ºµÄ´¦Àí£¬»ù±¾ÔÀí»¹ÊÇͳ¼ÆÒª½ØÈ¡µÄ×Ö½ÚÊýÖÐÊDZíʾºº×ÖµÄ×Ö½ÚÊýÊÇ·ñÊÇżÊý¸ö£¬¼´ÊÇ·ñ¸ÕºÃ°üÀ¨ÁËÍêÕûµÄºº×Ö¡£
/**
* ±à³Ì£º±àдһ¸ö½ØÈ¡×Ö·û´®µÄº¯Êý£¬ÊäÈëΪһ¸ö×Ö·û´®ºÍ×Ö½ÚÊý£¬Êä³öΪ°´×Ö½Ú½ØÈ¡µÄ×Ö·û´®¡£ µ«ÊÇÒª±£Ö¤ºº×Ö²»±»½Ø°ë¸ö£¬Èç“ÎÒABC”4£¬Ó¦¸Ã½ØΪ“ÎÒAB”£¬ÊäÈë“ÎÒABCººDEF”£¬6£¬Ó¦¸ÃÊä³öΪ“ÎÒABC”¶ø²»ÊÇ“ÎÒABC+ººµÄ°ë¸ö”¡£
* °´ÉÏÊö¹æÔò£¬ÊäÈë“ÎÒABCººDEF 1”£¬Ó¦·µ»Ø¿Õ×Ö·û´®£¬¶ø²»ÊÇ“ÎÒ”¡£
*/
public class CutMultibyte {
public static String cutMultibyte(String splitStr, int extract) {
byte[] bytes = splitStr.getBytes();
//½ØÈ¡×Ö½ÚÊý²»Ð¡ÓÚÔʼ×Ö½ÚÊýʱֱ½Ó·µ»ØÔ×Ö·û´®¡£×¢Òâ×Ö½ÚÊýÒ»¶¨ÒªÓà bytes.length£¬ÓÃ×Ö·û´®µÄ length() ·½·¨·µ»ØµÄÊÇ×Ö·ûÊý£¡
if (extract >= bytes.length) {
return splitStr;
}
else {
int result = 0;
int cutLength = 0;
//ͳ¼Æ³öÔÚÒª½ØÈ¡µÄ×Ö½ÚÖÐÓм¸¸ö×Ö½ÚÊǸºÊý
for (int i = 0; i < extract; i++) {
if (bytes[i] < 0) {
cutLength++;
}
}
//Èô¸ºÊý×Ö½ÚÊýÊÇżÊý£¬¼´Òª½ØÈ¡µÄ×Ö½ÚÊýÖÐÓöµ½¸ÕºÃÊÇÈô¸ÉÍêÕûµÄºº×Ö£¬Ôò½ØÈ¡×Ö½ÚÊý²»±ä£»·ñÔò¸ºÊý×Ö½ÚÊýÊÇÆæÊý£¬±íʾÓöµ½µÄ²»ÊÇÍêÕûºº×Ö£¬½ØÈ¡×Ö½ÚÊý¼õ 1¡£
if (cutLength % 2 == 0) {
result = extract;
}
else {
result = extract - 1;
}
String substrx = new String(bytes, 0, result);
return substrx;
}
}
public static void main(String args[]) {
String str = args[0];
int num = Integer.valueOf(ar
Ïà¹ØÎĵµ£º
ÿ¸öÍøÒ³»òÇëÇó¶¼ÊÇÒ»¸öurlµØÖ·£¬Ò»°ã£¬Õâ¸öµØÖ·¿ÉÄÜÊÇ.do,.page,.actionÖ®ÀàµÄ²¢¼ÓÉÏ'?'ºÅ¡¢'&'ºÅ²éѯ´®µÈ¹¹³ÉµÄÒ»¸ö³¤³¤µÄµÄurl¡£ºÜurgly¡£
Ò»°ãµÄurl----------------------------------------------------------½ÏºÃµÄurl
http://www.xxx.net/user/profile.do?id=20001 ====> http://www.xxx.ne ......
³¢ÊÔÓÃDOM4j½âÎöspringÅäÖÃÎļþʱ,µÚÒ»²½¶ÁÈ¡Îļþʱ£¬»ñȡ·¾¶¾ÍÓöµ½ÁËÎÊÌ⣬¡£¡£¡£¾¹ýgoogleÁËn+log n ´Î¸öÒ³Ã棬²ÅËãÓÐÁ˸ö´ÖdzµÄÈÏʶ£¬ÏÂÃæ¾ÍÈÃÎÒÓüò¶ÌµÄ»°ÓïÀ´×ܽáһϣ¨ºÃÏñÕâ¶Î¾ÍÈ«ÊÇ·Ï»°¡£¡£¡££©¡£¡£¡£
1¡¢springµÄÅäÖÃÎļþ´æ·ÅλÖÃÓÉweb.xmlÀïµÄcontextConfigLocationÀ´È·¶¨£¬Ò»°ãÊÇ·ÅÔÚweb-inf»òÕßÊÇsrc¸ùÄ¿Â¼Ï ......
Ö»Õë¶Ô²»Õý³£µÄÌõ¼þ²ÅʹÓÃÒì³£
Òì³£Ö»Ó¦¸Ã±»ÓÃÓÚ²»Õý³£µÄÌõ¼þ£¬ËüÃÇÓÀÔ¶²»Ó¦±»ÓÃÓÚÕý³£µÄ¿ØÖÆÁ÷¡£
ÏÂÃæÊÇÒ»¸öÓÃÒì³£×÷±éÀú½áÊøÌõ¼þµÄÀÄÓÃÒì³£µÄÀý×Ó£º
//horrible abuse of exceptions. Don't ever do this!
try{
int i=0;
while(true)a[i++].f();
}catch(ArrayIndexOutOfBoundsException e){
......