import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;
//从输入台接收五个数字,先进行排序,然后才在d盘的文档下再打印在输入台
public class Test03{
public static void main(String[] args) throws IOException{
System.out.println("请输入五个数字:");
int[] arr=new int[5];
Scanner sc=new Scanner(System.in);
for(int i=0;i<arr.length;i++){
arr[i]=sc.nextInt();
}
Arrays.sort(arr);
FileOutputStream fos=new FileOutputStream("D:\\xx.txt");
fos.write(Arrays.toString(arr).getBytes());
FileInputStream fis=new FileInputStream("D:\\xx.txt");
fos.close();
byte[] b=new byte[1024*8];
int len;
while((len=fis.read(b))!=-1){
System.out.println(new String(b,0,len));
}
fis.close();
}
}
|
|