举一反三
- 阅读下段代码import java.io.*;public class Example{public static void main(String[] args) throws Exception {FileInputStream fis = new FileInputStream("file.txt");FileOutputStream fos = new FileOutputStream("copy_file.txt");int ch = 0;while((ch =fis.read())!=-1){fos.write(ch);}fos._______;fis.close();}}请说出下划线上,填写的方法名称( ) A: write() B: close() C: available() D: read()
- 【单选题】阅读下段代码 import java.io.*; public class Example{ public static void main(String[] args) throws Exception { FileInputStream fis = new FileInputStream("file.txt"); FileOutputStream fos = n
- 阅读下段代码importjava.io.*;publicclassExample{publicstaticvoidmain(String[]args)throwsException{FileInputStreamfis=newFileInputStream("file.txt");FileOutputStreamfos=newFileOutputStream("copy_file.txt");intch=0;while((ch=fis.read())!=-1){fos.write(ch);}fos._______;fis.close();}}请说出下划线上,填写的方法名称
- 阅读下列代码 import java.io.*; public class Example { public static void main(String[] args) throws Exception { FileInputStream in = new FileInputStream("itcast.txt"); int b = 0; while (true) { b = in.______; if (b == -1) { break; } System.out.println(b); } in.close() } } 请说出下划线上,填写的方法名称
- 下列写法错误的是 A: File f = new File ("a.txt"); B: File f = new File ("d:\\a.txt"); C: FileInputStream fis = new FileInputStream (new File ("a.txt")); D: FileOutputStream fos = new FileOutputStream ( File ("."));
内容
- 0
阅读下列代码 import java.io.*; public class Example{ public static void main(String[] args) throws Exception { // 创建一个带缓冲区的输入流 BufferedInputStream bis = new BufferedInputStream(new ________( "src.txt")); // 创建一个带缓冲区的输出流 BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("des.txt")); int len; while ((len = bis.read()) != -1) { bos.write(len); } bis.close(); bos.close(); } } 请说出程序中,下划线位置的答案( )
- 1
下列哪个选项定义了带有缓存的文件字节输入流 A: BufferedInputStream bis = new BufferedInputStream(new FileInputStream(...)); B: BufferedOutputStream bos = new BufferedOutputStream(new FileInputStream(...)); C: FileInputStream fis = new FileInputStream(new BufferedInputStream(...)); D: FileOutputStream fis = new FileOutputStream(new BufferedOutputStream(...));
- 2
如果在一台 PC 机的c:\source目录运行如下代码: import java.io.*; class Path { public static void main(String[] args) throws Exception { File file = new File('Ran.test'); System.out.println(file.getAbsolutePath()); } } 则,期望的输出结果为?
- 3
有如下代码: public class Test{ public static void main(String args[]) { String str = new String("World"); char ch[] = {'H','e','l','l','o'}; change(str,ch); System.out.println(str + "and" + ch); } public static void change(String str, char ch[]) { str = "Changed"; ch[0] = 'C'; } } 运行后输出的结果是:
- 4
下列程序的功能是显示用户在命令行方式下指定的任意驱动器目录,请补充程序。 import java.iO.*; public class FindDirectories { public static void main (String args[ ]) { if(args.length= =0) args=new String[ ]".."}; try { File pathName=new File(args [0]); String[]fileName=pathName.list( ); for(int i=0;<fileName.length;i+ += { File f=new 【 】 if(f.isDirectory( )) { System.out.println(f.getCanonicalPath( )); main(new String[ ] { f.getPath( ) }); } } = catch(IOException e) { e.printStackTrace( ); } = =