这个问题还没解决啊,帮帮忙大家
class getbytes{
public static String getbg(String text,int leng){
try{
String txt="";
byte[] my=new byte[leng];
if(text.length()<leng) txt=text;
else{
byte[] mm=text.getBytes("ISO-8859-1");
for(int a=0;a<leng;a++){
my[a]=mm[a];
}
txt=new String(my,"GBK")+"......";
}
return txt;
}catch(java.io.UnsupportedEncodingException e){
}
return "";
}
public static void main(String ae[]){
System.out.println(getbytes.getbg("冰在之前sdffgh",10));
System.out.println(getbytes.getbg("冰在之前舶遥我扔手遥仍和",10));
System.out.println(getbytes.getbg("lsdkfalserpasdjjsdlfkjap",10));
System.out.println(getbytes.getbg("水水水水水水水水水水水水水",10));
}
}
----------------------------------------------------------------------
说明:
我想这样比如:
ieroerowier......
erioewoerow......
oeiwbxiuerk......
如果这里含有中文,因为中英站的字节数是不一样的么,输出来后长度不一样会
很难看,所以我才这样去转可是中文输出来的是乱码,请各位高手们指点一下该
怎么解决。谢谢!!谢谢!!谢谢!!谢谢!!谢谢!!谢谢!!谢谢!!!!