PackageCom.swift;ImportJava.io.FileInputStream;Importjava.io.FileNotFoundException;ImportJava.io.FileOutputStream;Importjava.io.IOException; Public classio_sort_content { Public Static voidMain (string[] args) {/** The contents of the known file A.txt file are "Bcdeadferwplkou", * please write the program to read the contents of the file, and in natural order after the output to the B.txt file. * That is, the contents of the file in B.txt should be "ABCD ..." In this order. */ Try{FileInputStream fis=NewFileInputStream ("E:\\neck\\a.txt"); FileOutputStream Fos=NewFileOutputStream ("E:\\neck\\b.txt"); byte[] kilo=New byte[4*1024]; intLen; while((Len=fis.read (kilo))!=-1) {fos.write (kilo,0, Len); Fos.flush (); } } Catch(FileNotFoundException e) {e.printstacktrace (); } Catch(IOException e) {e.printstacktrace (); } }}
Above just do read and write another file, and not sort
Here's how to sort
Java Exercise: Read the contents of the file and sort it in a natural order and output it to another file