• 2021-04-14
    在【1】-【5】处填上适当的代码,使程序能正常运行
    importjava.io.*;
    //将a.txt的内容复制到b.txt
    publicclassDemo{
    publicstaticvoidmain(String[]args)throwsIOException{
    【1】=newBufferedReader(newFileReader("a.txt"));
    BufferedWriterbw=newBufferedWriter(【2】);
    Strings1=null;
    【3】{
    while((s1=【4】.readLine())!=null){
    【5】.write(s1);
    System.out.print(s1);
    }
    }catch(IOExceptione){
    }finally{bw.close();br.close();}
    }
    }

  • BufferedReaderbr  newFileWriter("b.txt")  try  br  bw

    内容

    • 0

      若文本文件a.txt中的内容如下:abcdef123456则下列程序的执行结果是__。f=open(a.txt,r)s=f.readlines1=list(s)print(s1)A.['abcdef\n']B.['a','b','c','d','e','f','\n']C A: 1 B: 2 C: 3 D: 4

    • 1

      在搜索文件或文件夹时,若用户选择通配符a?.txt,则下列被选中的文件是() (1)A12.txt (2)A1.txt (3)A.txt (4)a1.doc (5)aa.txt A: (1)(2)(5) B: (1)(2)(3)(5) C: (2)(5) D: (2)(3)(5)

    • 2

      写出下列程序的运行结果 s='abcdefg' print(s[3]) print(s[3:5]) print(s[:5]) print(s[3:]) print(s[::2]) print(s[::-1]) print(s[-2:-5])

    • 3

      给出以下代码: s=”students” print(s.count(“s”)) print(s.count(s)) 上述代码的运行结果是( )。 A: s s B: s 1 C: 2 1 D: 1 1

    • 4

      下列代码片段执行结果是:String s=new String(”abc”); String s1=new String(s); if(s==s1){ System.out.println(”Hello”); } if(s.equals(s1)){ System.out.println(”World”); } A: Hello World B: Hello C: World D: Null