用“new FileOutputStream("data.txt",true)”创建一个FileOutputStream对象,则下面说法哪个错误的? ()
A. 如果文件data.txt不存在,也不一定会抛出IOException异常
B. 如果文件data.txt不存在,则可能会新建文件data.txt
C. 如果文件data.txt存在,则将覆盖掉文件中原有的内容
D. 如果文件data.txt存在,则从文件的末尾开始添加新内容
查看答案
下列选项中,那些事标准输入输出流?()(多选)
A. System.In
B. System.Out
C. InputStream
D. OutputStream
文件E.java的长度是51个字节,请说出E类中标注的【代码1】,【代码2】的输出结果。import java.io.*;public class E {public static void main(String args[]) {File f = new File("E.java");try{ RandomAccessFile in = new RandomAccessFile(f,"rw");System.out.println(f.length()); //【代码1】FileOutputStream out = new FileOutputStream(f);System.out.println(f.length()); //【代码2】} catch(IOException e) {System.out.println("File read Error"+e);}}}
请说出E类中标注的【代码1】~【代码4】的输出结果。import java.io.*;public class E {public static void main(String args[]) {int n=-1;File f =new File("hello.txt");byte [] a="abcd".getBytes();try{ FileOutputStream out=new FileOutputStream(f);out.write(a);out.close();FileInputStream in=new FileInputStream(f);byte [] tom= new byte[3];int m = in.read(tom,0,3);System.out.println(m);//【代码1】String s=new String(tom,0,3);System.out.println(s);//【代码2】m = in.read(tom,0,3);System.out.println(m);//【代码3】s=new String(tom,0,3);System.out.println(s);//【代码4】}catch(IOException e) {}}}
下列程序实现从控制台逐行读取并输出字符串. 请将程序补充完整import java.io.*;public class CharInput{public static void main(String args[]) throws java.io.IOException}String s;inputStreamReader ir;BufferedReader in;ir=new[1] (System.io);in=new_____[2] ____(ir);while ((s=in.____ [3] ___)!=null){System.out.println(“Read;”+s);}}}