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);

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);

相关考题:

本题的功能是将文件java2.java复制为文件java2.java.bak。 importjava.io.*; public class java2{ public static void main(String sarg[]){ try{File file=new File("java2.java.bak"); ; FilelnputStream rfile=new FilelnputStream("ja- va2.java"); FileOutputStream wfile=new FileOutputStream ("java2.java.bak"); int c; while( ) wfile.write((char)c); rfile.close; wfile.close; }catch(Exception e){System.out.println("读取文 件的时候发生错误!");} System.out.println("复制操作完成!"); } }

下列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);

WhichtwocreateanInputStreamandopenfilethe“file.txt”forreading?() A.InputStreamin=newFileReader(“file.txt”);B.InputStreamin=newFileInputStream(“file.txt”);C.InputStreamin=newInputStreamFileReader(“file.txt”,“read”);D.FileInputStreamin=newFileReader(newFile(“file.txt”));E.FileInputStreamin=newFileInputStream(newFile(“file.txt”));

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”);

下面程序的功能是从键盘读取一行文本并将该文本存储到文件中。当用户运行该程序时,需要输入一行文本并按下回车键。然后在DOS系统提示符处输入type file.txt并按下Enter键,这时屏幕会显示type file.txt的内容。通过这个命令可以验证该程序的功能。请在每条横线处填写一条语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。源程序文件代码清单如下:import java.io.*;public class DoFile{public static void main(String args[]){byte buffername[]=______[80];try{System.out.println("\nEnter a line to be saved to disk:");int bytesbleck= ______;FileOutputStream f=new FileOutputStream("file.txt");______;}catch(Exception e){e.printStackTrace();}}}

( 34 )在下列程序的空白处,应填入的正确选项是Import java.io.*;Pulilc class ObjectStreamTest{Publilc static void main(string args[]) throws IOException{ObjectOutputStream s= new ObjectOutputStream(new FileOutputStream( “ serial.bin ” ));Java .util.Date d= new Java.util.Date();Oos___________ (d);ObjectInputStream is=new ObjectInputStream(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 statements are true, given the code new FileOutputStream("data", true) for creating an object of class FileOutputStream?()  A、FileOutputStream has no constructors matching the given arguments.B、An IOExeception will be thrown if a file named "data" already exists.C、An IOExeception will be thrown if a file named "data" does not already exist.D、If a file named "data" exists, its contents will be reset and overwritten.E、If a file named "data" exists, output will be appended to its current contents.

假设文件“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();

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”));

判断题假设文件“a.txt”的长度为100字节,那么当正常运行语句“OutputStream f = new FileOutputStream(new File(“a.txt”));”之后,文件“a.txt”的长度变为0字节。()A对B错

单选题在下列程序的空白处,应填入的正确选项是(  )。import java.io.*;public class ObjectStreamTest{public static void main(string args[])throws IOException{ ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream("serial.bin")); Java.until.Date d=new Java.until.Date(); oos.______(); ObjectInputStream ois=new ObjectlnputStream(new FileOutputStream("serial.bin")); try{ java.until.date restoredDate=(Java.until.Date)ois.readObject(); System.out.println("read object back from serial.bin file:"+restoredDate); } catch(ClassNotFoundException cnf){ System.out.println("class not found"); }}AreadObjectBWriterCBufferedWriterDwriteObject

多选题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”));

多选题创建一个向文件“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”)