阅读下段代码import java.io.*;public class Example { public static void main(String[] args) throws Exception {byte[] bufs = new byte[] { 97, 98, 99, 100 };// 创建一个字节数组ByteArrayInputStream bis = new ByteArrayInputStream(bufs);//读取字节数组中的数据//下面的代码是循环读取缓冲区中的数据 int b;while ((b = bis.read()) != -1) {System.out.print((char) b+",");} }}下列选项中,哪一个是程序的运行结果( )
A. 97,98,99,100,
B. 100,99,98,97,
C. a,b,c,d,
D. A,B,C,D,
查看答案
阅读下列代码import java.io.*;public class Example{public static void main(String[] args) throws Exception {OutputStream out = new FileOutputStream("itcast.txt ", true);String str = "欢迎你!";byte[] b = str.getBytes();for (int i = 0; i < b.length; i++) {out.______(b[i]);}out.close(); }}下列选项中,哪个填写在程序空白处会使程序正确。
A. read()
B. write()
C. close()
D. available()
阅读下列代码import java.io.*;public class Example{public static void main(String[] args) throws Exception { File file = new File("itcast.txt"); FileInputStream in = new FileInputStream(file); // 以下是用缓冲区读写文件byte[] buff = new byte[1024]; // 定义一个字节数组,作为缓冲区int len; while ((len = in.______) != -1) { // 判断是否读到文件末尾System.out.println(new String(buff,0,len));}in.close(); }}下列选项中,哪个填写在空白处,程序不会报错。
A. read(buff)
B. read()
C. write(buff)
D. write()
请将下列四个步骤进行排列,完成文件的拷贝操作( )① 将字节流输入流和源文件相关联,输出流和目标文件相关联。② 明确源文件和目标文件。③ 使用输入流的读取方法读取文件,并将字节写入到目标文件中。④ 关闭资源。
A. ①②③④
B. ②①③④
C. ②③①④
D. ①③②④
使用FileReader读取reader.txt文本文件中的数据,reader.txt中的内容为:abcimport java.io.*;public class Example01 { public static void main(String[] args) throws Exception {FileReader reader = new FileReader("reader.txt");int ch;while ((ch = reader.read()) != -1) {System.out.print(ch+" ");}reader.close(); }}运行以上程序的结果是( )
A. 编译出错
B. a b c
C. 97 98 99
D. 无输出