public void cutString(String str,int n)
{
String temp;
int count=0;
for (int i = 0; i < str.length(); i++) {
temp=str.charAt(i)+"";
count+=temp.getBytes().length;
if(count>n)
break;
System.out.print(temp);
}
}
@Test
public void testString()
{
cutString("我ABC好的sfd", 7);
}
{
String temp;
int count=0;
for (int i = 0; i < str.length(); i++) {
temp=str.charAt(i)+"";
count+=temp.getBytes().length;
if(count>n)
break;
System.out.print(temp);
}
}
@Test
public void testString()
{
cutString("我ABC好的sfd", 7);
}