//这是我写的,你可以看看,如果写的不好欢迎指正
我也是初学者。。。
public class CreateandInput {
public static void main(String[] args) throws IOException {
File f=new File("E:\\Exercise12_15.txt");
f.createNewFile();
BufferedWriter bw=new BufferedWriter(new FileWriter(f));
Random r=new Random(47);
for(int i=0;i<100;i++)
bw.write(r.nextInt(1000)+" ");
bw.close();
BufferedReader br=new BufferedReader(new FileReader(f));
String s;
StringBuilder sb=new StringBuilder();
while((s=br.readLine())!=null)
sb.append(s);
String[] s1=sb.toString().split(" ");
Integer[] result=new Integer[s1.length];
for(int i=0;i<s1.length;i++)
result[i]=Integer.parseInt(s1[i]);
Arrays.sort(result);
for(Integer inte:result) {
System.out.println(inte);
}
}
}