Public class demo {public static void main (string [] ARGs) {for (INT I = 0; I <15; I ++) {system. out. print ("truncated to" + I + "bit:"); splitstr ("I zwr love Java", I) ;}} public static void splitstr (string STR, int bytes) {int end = 0; For (INT I = 0, Len = Str. length (); I <Len; I ++) {If (ischinesechar (Str. charat (I) {bytes --;} bytes --; If (Bytes> = 0) {end = I + 1;} else {break;} system. out. println (Str. substring (0, end);} Private Static Boolean ischinesechar (char c) {return string. valueof (c ). getbytes (). length> 1;} // capture to 0th bits: // capture to 1st bits: // capture to 2nd bits: I // capture to 3rd bits: I z // capture to 4th bits: I zw // capture to 5th bits: I zwr // capture to 6th bits: I zwr // capture to 7th bits: I love zwr // capture to 8th: I love zwr J // capture to 9th: I love zwr ja // capture to 10th: I love Jav zwr // capture to 11th bits: I love Java zwr // capture to 12th bits: I love Java zwr // capture to 13th bits: I love Java in zwr. // I love Java in zwr}