import java.io.*;
import java.util.Arrays;
public class test02 {
/**
* @param args
*/
public static void main (String[] args)
{
// TODO Auto-generated method stub
System.out.println("Please input a String:");
DataInputStream d=new DataInputStream(System.in);
BufferedInputStream b=new BufferedInputStream(d);
//Arrays nstr;
String instr;
byte in[]=new byte[10000];
int count;
try{
count=b.read(in);
instr=new String(in,0,count);
System.out.println("you entered:");
System.out.println(instr);
System.out.println("排序后是:");
char ch[]=new char[count];
ch=instr.toCharArray();
/*for(int i=0;i<count;i++)
{
for(int j=0;j<count-i-1;j++)
{
if(ch[j]>ch[j+1])
{
char temp;
temp=ch[j+1];
ch[j+1]=ch[j];
ch[j]=temp;
}
}
}*/
Arrays.sort(ch);
instr=ch.toString();
System.out.println(instr);
d.close();
b.close();
}catch(IOException e)
{
e.getStackTrace();
}
}
}
为什么我输入一个字符串,排序后就成乱码了!!!!