Which constructs a DataOutputStream?()  A、 New dataInputStream(“in.txt”);B、 New dataInputStream(new file(“in.txt”));C、 New dataInputStream(new writer(“in.txt”));D、 New dataInputStream(new FileWriter(“in.txt”));E、 New dataInputStream(new InputStream(“in.tx

题目

Which constructs a DataOutputStream?()  

  • A、 New dataInputStream(“in.txt”);
  • B、 New dataInputStream(new file(“in.txt”));
  • C、 New dataInputStream(new writer(“in.txt”));
  • D、 New dataInputStream(new FileWriter(“in.txt”));
  • E、 New dataInputStream(new InputStream(“in.txt”));
  • F、 New dataInputStream(new FileInputStream(“in.txt”));
如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

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


参考答案:C

第2题:

请完成下列Java程序:实现打印出自己的源文件的功能。

注意:请勿改动main()主方法和其他已有语句内容,仅在下划线处填入适当的语句。

import java.io.*;

import java.util.StringTokenizer;

public class ex27_2{

public static void main(String args[])throws IOException{

FileInputStream fis=new FileInputStream("ex27_2.java");

DataInputStream dis=new DataInputStream(fis);

String str=null;

while(true){

__________________;

if(str==null){

__________________;

}

StringTokenizer st=new StringTokenizer(str);

while(st.hasMoreTokens()){

System.out.print(st.nextToken()+ " " );

}

System.out.println();

}

}

}


正确答案:str=dis.readLine() break
str=dis.readLine() break 解析:本题主要考查文件I/O操作和while语句,if语句的使用。解题关键是熟悉文件I/O操作的基本方法,以及利用while语句和if语句控制程序流程。本题中,第1个空,DataInputStream的对象dis调用readLine()方法,从输入流中读取数据,并写给String类的str对象;第二空,如果str为空,则跳出循环体,这里使用break完成跳转。

第3题:

在J2EE中,某一java程序中有如下代码:DataInputStream din=new DataInputStream(new BufferedInputStream(new FileInputStream("employee.dat")));System.out.print(din.readByte());假设在employee.dat文件中只有如下一段字符:abcdefg。则:System.out在屏幕上打印()。

A.a

B.b

C.97

D.98


参考答案:C

第4题:

在J2EE中,下面代码中,()不会编译错误。    

  • A、File f = new File("/","autoexec.bat");
  • B、DataInputStream din = new DataInputStream(new FileInputStream("autoexec.bat"));
  • C、InputStreamReader in = new InputStreamReader(System.in);
  • D、OutputStreamWriter out = new OutputStreamWriter(System.in);

正确答案:A,B,C

第5题:

欲新建一个电路原理图文件应该执行()操作。

  • A、File/New/Schematic
  • B、File/New/PCB
  • C、File/New/SchematicLibrary
  • D、File/New/PCBLibrary

正确答案:A

第6题:

Given that the current directory is empty, and that the user has read and write privileges to the current, and the following:Which statement is true?()

A.Compilation fails.

B.Nothing is added to the file system.

C.Only a new file is created on the file system.

D.Only a new directory is created on the file system.

E.Both a new file and a new directory are created on the file system.


参考答案:B

第7题:

What command would an operator use to move a file from the /old_dir directory to the /new_dir directory without changing the file name?()

A. mv /old_dir/file /new_dir

B. mv -p /old_dir/file /new_dir

C. mv -k /old_dir/file /new_dir

D. mv /old_dir/file /new_dir/new_file


参考答案:A

第8题:

下面创建一个新文件对象方法错误的是( )。

A.File myFile; myFile=new File("mulu/file");

B.File myFile=new File();

C.myFile=new FileC/mulu","filel");

D.File myDir=new file("/mulu"); myFile=new File(Dir, "filer');


正确答案:B

第9题:

创建一个向文件“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.;

正确答案:A,E

第10题:

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

正确答案:C,E

更多相关问题