单选题What writes the text “ ” to the end of the file “file.txt”?()A OutputStream out= new FileOutputStream (“file.txt”); Out.writeBytes (“ /n”);B OutputStream os= new FileOutputStream (“file.txt”, true); DataOutputStream out = new DataOutputStream(os); out.writeBytes (“ /n”);C OutputStream os= new FileOutputStream (“file.txt”); DataOutputStream out = new DataOutputStream(os); out.writeBytes (“ /n”);D OutputStream os= new OutputStream (“file.txt”, true); DataOutputStream out = new DataOutputStream(os); out.writeBytes (“ /n”);
单选题
What writes the text “ ” to the end of the file “file.txt”?()
A
OutputStream out= new FileOutputStream (“file.txt”); Out.writeBytes (“ /n”);
B
OutputStream os= new FileOutputStream (“file.txt”, true); DataOutputStream out = new DataOutputStream(os); out.writeBytes (“ /n”);
C
OutputStream os= new FileOutputStream (“file.txt”); DataOutputStream out = new DataOutputStream(os); out.writeBytes (“ /n”);
D
OutputStream os= new OutputStream (“file.txt”, true); DataOutputStream out = new DataOutputStream(os); out.writeBytes (“ /n”);
参考解析
解析:
暂无解析
相关考题:
下列InputStream构造方法正确的是()。 A、InputStream in=new FileReader(“file.txt”)B、InputStream in=new FileInputStream(“file.txt”)C、InputStream in=new InputStreamFileReader (“file.txt”,“read”)D、FileInputStream in=new FileReader(new File(“file.txt”))
要想以读方式打开文件“D:\File.txt”,以下不能实现目的的语句是()。A、ifstreaminf("D:\\FilEtxt",ios::in);B、ifstreaminf("D:\\File.txt");C、ofstreaminf("D:\\File.txt",ios::out);D、fstreaminf("D:\\File.txt",ios::in|ios::out);
WhichtwoconstructanOutputSreamthatappendstothefile“file.txt”?() A.OutputStreamout=newFileOutputStream(“file.txt”);B.OutputStreamout=newFileOutputStream(“file.txt”,“append”);C.FileOutputStreamout=newFileOutputStream(“file.txt”,true);D.FileOutputStreamout=newFileOutputStream(newfile(“file.txt”));E.OutputStreamout=newFileOutputStream(newFile(“file.txt”)true);
Whatwritesthetext“”totheendofthefile“file.txt”?() A.OutputStreamout=newFileOutputStream(“file.txt”); Out.writeBytes(“/n”);B.OutputStreamos=newFileOutputStream(“file.txt”,true); DataOutputStreamout=newDataOutputStream(os);out.writeBytes(“/n”);C.OutputStreamos=newFileOutputStream(“file.txt”); DataOutputStreamout=newDataOutputStream(os);out.writeBytes(“/n”);D.OutputStreamos=newOutputStream(“file.txt”,true); DataOutputStreamout=newDataOutputStream(os);out.writeBytes(“/n”);
阅读下面写文件的程序 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.myArrayB.dosC.ioeD.ints
在下列程序的空白处,应填入的正确选项是( )。 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.WriterObjectB.WriterC.BufferedWriterD.writerObject
( 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; i50000; i++){os.write(1);}}os.close();return(int)(()new Date()).getTime() - then.getTime());}
创建一个向文件“file.txt”追加内容的输出流对象的语句有()。A、FileOutputStream out=new FileOutputStream(“file.txt”,true);B、OutputStream out=new FileOutputStream(“file.txt”,“append”);C、OutputStream out=new FileOutputStream(“file.txt”);D、FileOutputStream out=new FileOutputStream(new file(“file.txt”));E、OutputStream out=new FileOutputStream(new File(“file.txt”),true.;
Which two construct an OutputSream that appends to the file “file.txt”? ()A、 OutputStream out=new FileOutputStream(“file.txt”);B、 OutputStream out=new FileOutputStream(“file.txt”, “append”);C、 FileOutputStream out=new FileOutputStream(“file.txt”, true);D、 FileOutputStream out=new FileOutputStream(new file(“file.txt”));E、 OutputStream out=new FileOutputStream(new File(“file.txt”)true);
假设文件“a.txt”的长度为100字节,那么当正常运行语句“OutputStream f = new FileOutputStream(new File(“a.txt”));”之后,文件“a.txt”的长度变为0字节。()
为文件c:/java/example/file.txt建立File对象file1可以采用()语句序列。A、File file 1=new File(“c://java//example//file.txt”)B、String path=”c:/java/example/”Filefile1=newFile(path,”oldfile.txt”)C、File dir 1=new File(“c://java//example”)Filefile1=newFile(dir1,”oldfile.txt”)D、File file 1=new File(“c:/java//example/file.txt”)
Which two create an InputStream and open file the “file.txt” for reading? ()A、 InputStream in=new FileReader(“file.txt”);B、 InputStream in=new FileInputStream(“file.txt”);C、 InputStream in=new InputStreamFileReader (“file.txt”, “read”);D、 FileInputStream in=new FileReader(new File(“file.txt”));E、 FileInputStream in=new FileInputStream(new File(“file.txt”));
Which constructs a DataOutputStream?()A、 New dataOutputStream(“out.txt”);B、 New dataOutputStream(new file(“out.txt”));C、 New dataOutputStream(new writer(“out.txt”));D、 New dataOutputStream(new FileWriter(“out.txt”));E、 New dataOutputStream(new OutputStream(“out.txt”));F、 New dataOutputStream(new FileOutputStream(“out.txt”));
Which gets the name of the parent directory file “file.txt”?()A、 String name= File.getParentName(“file.txt”);B、 String name= (new File(“file.txt”)).getParent();C、 String name = (new File(“file.txt”)).getParentName();D、 String name= (new File(“file.txt”)).getParentFile();E、 Directory dir=(new File (“file.txt”)).getParentDir(); String name= dir.getName();
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?() A、 Compilation fails.B、 An exception is thrown at runtime.C、 An instance of Forest is serialized.D、 A instance of Forest and an instance of Tree are both serialized.
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?()A、 The code does not compile.B、 The code runs and no change is made to the file.C、 The code runs and sets the length of the file to 0.D、 An exception is thrown because the file is not closed.E、 The code runs and deletes the file from the file system.
What writes the text “ ” to the end of the file “file.txt”?()A、 OutputStream out= new FileOutputStream (“file.txt”); Out.writeBytes (“ /n”);B、 OutputStream os= new FileOutputStream (“file.txt”, true); DataOutputStream out = new DataOutputStream(os); out.writeBytes (“ /n”);C、 OutputStream os= new FileOutputStream (“file.txt”); DataOutputStream out = new DataOutputStream(os); out.writeBytes (“ /n”);D、 OutputStream os= new OutputStream (“file.txt”, true); DataOutputStream out = new DataOutputStream(os); out.writeBytes (“ /n”);
单选题Which constructs a DataOutputStream?()A New dataOutputStream(“out.txt”);B New dataOutputStream(new file(“out.txt”));C New dataOutputStream(new writer(“out.txt”));D New dataOutputStream(new FileWriter(“out.txt”));E New dataOutputStream(new OutputStream(“out.txt”));F New dataOutputStream(new FileOutputStream(“out.txt”));
单选题在下列程序的空白处,应填入的正确选项是( )。import java.io.*;public class writeInt{public static void main(String[] args){int[] myArray={10,20,30,40};try{ DataOutputStream dos=new DataOutputStream(new FileOutputStream("ints.dat")); for(int i=0;i dos.writeInt(myArray[i]); dos.close(); System.out.println("Have written binary file ints.dat");}}catch(IOException ioe){ System.out.println("IOException");}}}Astart()Bclose()Cread()Dwrite()
判断题假设文件“a.txt”的长度为100字节,那么当正常运行语句“OutputStream f = new FileOutputStream(new File(“a.txt”));”之后,文件“a.txt”的长度变为0字节。()A对B错
多选题Which two create an InputStream and open file the “file.txt” for reading? ()AInputStream in=new FileReader(“file.txt”);BInputStream in=new FileInputStream(“file.txt”);CInputStream in=new InputStreamFileReader (“file.txt”, “read”);DFileInputStream in=new FileReader(new File(“file.txt”));EFileInputStream in=new FileInputStream(new File(“file.txt”));
单选题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?()A Compilation fails.B An exception is thrown at runtime.C An instance of Forest is serialized.D A instance of Forest and an instance of Tree are both serialized.
多选题创建一个向文件“file.txt”追加内容的输出流对象的语句有()。AFileOutputStream out=new FileOutputStream(“file.txt”,true);BOutputStream out=new FileOutputStream(“file.txt”,“append”);COutputStream out=new FileOutputStream(“file.txt”);DFileOutputStream out=new FileOutputStream(new file(“file.txt”));EOutputStream out=new FileOutputStream(new File(“file.txt”),true.;
单选题Which gets the name of the parent directory file “file.txt”?()A String name= File.getParentName(“file.txt”);B String name= (new File(“file.txt”)).getParent();C String name = (new File(“file.txt”)).getParentName();D String name= (new File(“file.txt”)).getParentFile();E Directory dir=(new File (“file.txt”)).getParentDir(); String name= dir.getName();
多选题Which two construct an OutputSream that appends to the file “file.txt”? ()AOutputStream out=new FileOutputStream(“file.txt”);BOutputStream out=new FileOutputStream(“file.txt”, “append”);CFileOutputStream out=new FileOutputStream(“file.txt”, true);DFileOutputStream out=new FileOutputStream(new file(“file.txt”));EOutputStream out=new FileOutputStream(new File(“file.txt”)true);
单选题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?()A The code does not compile.B The code runs and no change is made to the file.C The code runs and sets the length of the file to 0.D An exception is thrown because the file is not closed.E The code runs and deletes the file from the file system.
多选题为文件c:/java/example/file.txt建立File对象file1可以采用()语句序列。AFile file 1=new File(“c://java//example//file.txt”)BString path=”c:/java/example/”Filefile1=newFile(path,”oldfile.txt”)CFile dir 1=new File(“c://java//example”)Filefile1=newFile(dir1,”oldfile.txt”)DFile file 1=new File(“c:/java//example/file.txt”)