What writes the text “ ” to the end of the file “file.txt”?()
第1题:
阅读下面写文件的程序 import java. io. *; public class WriteFile{ public static void main(String[]A) { int[]myArray={10,20,30,40}; try{ FileOutputStream f=new FlieOutStream("ints. dat"); DataOutputStream______=new DataOutputStream(f); for(int i=0; i<myArray. length; i ++) dos. writeInt(myArray[i]); dos. close(); System. out. prinfln("Have written binary file ints. dat"); } catch(IOException ioe){ System. out. println("IO Exception"); } } 在程序下画线处填入的正确选项是
A.myArray
B.dos
C.ioe
D.ints
第2题:
在下列程序的空白处,应填入的正确选项是( )。 Import java.io.*; Pulilc class ObjectStreamTest{ Publilc static void main(string args[])throws IOEx- ception{ OhiectOutputStream os=new OhjectOutputStream (new FileOutputStream("serial.bin")); Java.util.Date d=new Java.util.Date; Oos (d); ObjectInputStream is= new OhjectlnputStream(new FileOutputStream("serial. bin")); try{ java.util.date restoredDate= (Java.util.Date)ois.readObject; System.out.println ("read object back from serial.bin file:" +restoredDate); } Catch(ClassNotFoundException cnf){ System.out.println("class not found"); } }
A.WriterObject
B.Writer
C.BufferedWriter
D.writerObject
第3题:
创建一个向文件“file.txt”追加内容的输出流对象的语句有()。
第4题:
假设文件“a.txt”的长度为100字节,那么当正常运行语句“OutputStream f = new FileOutputStream(new File(“a.txt”));”之后,文件“a.txt”的长度变为0字节。()
第5题:
Which two create an InputStream and open file the “file.txt” for reading? ()
第6题:
Which gets the name of the parent directory file “file.txt”?()
第7题:
The file “file.txt” exists on the file system and contsins ASCII text. Given: try { File f = new File(“file.txt”); OutputStream out = new FileOutputStream(f, true); } catch (IOException) {} What is the result?()
第8题:
start()
close()
read()
write()
第9题:
InputStream in=new FileReader(“file.txt”);
InputStream in=new FileInputStream(“file.txt”);
InputStream in=new InputStreamFileReader (“file.txt”, “read”);
FileInputStream in=new FileReader(new File(“file.txt”));
FileInputStream in=new FileInputStream(new File(“file.txt”));
第10题:
FileOutputStream out=new FileOutputStream(“file.txt”,true);
OutputStream out=new FileOutputStream(“file.txt”,“append”);
OutputStream out=new FileOutputStream(“file.txt”);
FileOutputStream out=new FileOutputStream(new file(“file.txt”));
OutputStream out=new FileOutputStream(new File(“file.txt”),true.;
第11题:
OutputStream out=new FileOutputStream(“file.txt”);
OutputStream out=new FileOutputStream(“file.txt”, “append”);
FileOutputStream out=new FileOutputStream(“file.txt”, true);
FileOutputStream out=new FileOutputStream(new file(“file.txt”));
OutputStream out=new FileOutputStream(new File(“file.txt”)true);
第12题:
File file 1=new File(“c://java//example//file.txt”)
String path=”c:/java/example/”Filefile1=newFile(path,”oldfile.txt”)
File dir 1=new File(“c://java//example”)Filefile1=newFile(dir1,”oldfile.txt”)
File file 1=new File(“c:/java//example/file.txt”)
第13题:
阅读下面写文件的程序 import java.io.*: public class WriteFile{ public static void main(String[] A) { int[] myArray={10,20,30,40}; try { FileOutputStream f=new FileOutputStream("ints.dat"); DataOutputStream ______ =new DataOutputStream(f); for(int i=0;i<myArray.length;i++)dos.writeInt(myArray[i]); dos.close(); System.out.println("Have written binary file ints.dat"); } catch(IOException ioe) { System.out.println("IOException"); } } } 程序中下画线处应填入的正确选项是
A.myArray
B.dos
C.ioe
D.ints
第14题:
( 11 )请在下列程序的空白处,填上适当的内容:
Import java. awt. *;
Import java. util. *;
Class BufferTest{
Public static void main(string args[])
Throws IOException{
FileOutputStream unbuf=
new FileOutputStream( “ test.one ” ) ;
BufferedOutputStream buf=
new 【 11 】 (new FileOutputStream( “ test.two ” ));
System.out.println
( “ write file unbuffered: ” + time(unbuf) + “ ms ” );
System.out.println
( “ write file buffered: ” + time(buf) + “ ms ” );
}
Static int time (OutputStream os)
Throws IOException{
Date then = new Date();
for (int i=0; i<50000; i++){
os.write(1);
}
}
os.close();
return(int)(()new Date()).getTime() - then.getTime());
}
第15题:
Which two construct an OutputSream that appends to the file “file.txt”? ()
第16题:
为文件c:/java/example/file.txt建立File对象file1可以采用()语句序列。
第17题:
Which constructs a DataOutputStream?()
第18题:
import java.io.*; public class Forest implements Serializable { private Tree tree = new Tree(); public static void main(String [] args) { Forest f= new Forest(); try { FileOutputStream fs = new FileOutputStream(”Forest.ser”); ObjectOutputStream os = new ObjectOutputStream(fs); os.writeObject(f); os.close(); } catch (Exception ex) { ex.printStackTrace(); } } } class Tree { } What is the result?()
第19题:
New dataOutputStream(“out.txt”);
New dataOutputStream(new file(“out.txt”));
New dataOutputStream(new writer(“out.txt”));
New dataOutputStream(new FileWriter(“out.txt”));
New dataOutputStream(new OutputStream(“out.txt”));
New dataOutputStream(new FileOutputStream(“out.txt”));
第20题:
对
错
第21题:
Compilation fails.
An exception is thrown at runtime.
An instance of Forest is serialized.
A instance of Forest and an instance of Tree are both serialized.
第22题:
String name= File.getParentName(“file.txt”);
String name= (new File(“file.txt”)).getParent();
String name = (new File(“file.txt”)).getParentName();
String name= (new File(“file.txt”)).getParentFile();
Directory dir=(new File (“file.txt”)).getParentDir(); String name= dir.getName();
第23题:
The code does not compile.
The code runs and no change is made to the file.
The code runs and sets the length of the file to 0.
An exception is thrown because the file is not closed.
The code runs and deletes the file from the file system.