package test01;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.Arrays;
public class Test01_1 {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new FileReader("data.txt"));
String s = null;
String str = "";
while((s=br.readLine())!=null) {
str += s;
}
char[] cs = str.toCharArray();
//用选择排序对字符数组进行排序
for(int i = 0;i<cs.length-1;i++) {
for(int j=i+1;j<cs.length;j++) {
if(cs[i] >cs[j]) {
char temp = cs[i];
cs[i] = cs[j];
cs[j] = temp;
}
}
}
//Arrays.sort(cs);
System.out.println(Arrays.toString(cs));
}
}
|
|