问答题

现有磁盘文件filea.txt和fileb.txt,各存放一行字母,上述程序实现了将2个磁盘文件中的内容合并,并按照字母的升序排列,存放到一个新的文件new.txt中。请将程序补充完整。 注意:不改动程序结构,不得增行或删行。 package ch3; import java.util.*; import java.io.*; public class ex3 { public static void main(String[] args) { String s=""; try { RandomAccessFile f1= new RandomAccessFile("ch3/filea.txt","rw"); ______f2=new ______("ch3/fileb.txt","rw"); s=f1.readLine()+f2.readLine(); char c[]=s.toCharArray(); Arrays.sort(c); ______Out=new______("ch3/new.txt"); for(int i=0;i<c.length;i++) { Out.______(c[i]); } out.______; f1.close(); f2.close(); } catch(I0Exception ioe) { ioe.printStackTrace(); } } }

【参考答案】

RandomAccessFile RandomAccessFile FileOutputStream PileOutpu......

(↓↓↓ 点击下方‘点击查看答案’看完整答案 ↓↓↓)
热门 试题