下列程序实现对ZIP 文件file. zip 的检索,在横线处填入正确的语句是( )。package test;import jav
A: io.*;
B: import java. util.*;
C: import java. util. zip.*;
D: public class Exam
E: public static void main(String[] args)
F: try
G: FileInputStream fis = new FilelnputStream("test/file.zip");
H: ZipInputStream zis = new ZiplnputStream(fis);
I: ZipEntry en;
J: while ((______ )!= null)
K: en. getName();
L: zis. closeEntry();
M: zis. close();
N: catch(Exception e)e. pfintStackTrace();
O: en = zis. getNextEntry()B. en == zis.getNextEntry(C. en=zis. getEntry()D. zis.getNextEntry()
A: io.*;
B: import java. util.*;
C: import java. util. zip.*;
D: public class Exam
E: public static void main(String[] args)
F: try
G: FileInputStream fis = new FilelnputStream("test/file.zip");
H: ZipInputStream zis = new ZiplnputStream(fis);
I: ZipEntry en;
J: while ((______ )!= null)
K: en. getName();
L: zis. closeEntry();
M: zis. close();
N: catch(Exception e)e. pfintStackTrace();
O: en = zis. getNextEntry()B. en == zis.getNextEntry(C. en=zis. getEntry()D. zis.getNextEntry()
举一反三
- 下列程序运行后的结果可能是________。import java. io. *;public class Test { public static void main (String [] args) { File file =new File ( "hello . txt" ) ; if (file. exists () ) { file.delete () ; } else { try { file . createNewFile ( ) ; } catch (Exception e ) { e .printStackTrace ( ) ; } } }} A: 如果文件不存在 ,则程序退出 B: 如果文件已经存在 , 则程序退出 C: 如果文件已经存在,则保留该文件 D: 如果文件不存在 , 则创建该文件
- 【单选题】阅读下段代码 import java.io.*; public class Example{ public static void main(String[] args) throws Exception { FileInputStream fis = new FileInputStream("file.txt"); FileOutputStream fos = n
- 从对象流中读取对象,请在下面横线处填写代码完成此程序。 import java.util. *; import java. io. *; public class UnSerializeDate { date d = null; UnSerializeDate ( ) { try { FileInputStream f1 = new FileInputStream("date.ser"); d = (Date) s. readobject (); f1,close(); } catch (Exceptin e) { e. printStackTrace (); } } public static main(String args [] ) { System.out.println("The date read is: "+ a.d.toString()); } }
- (对象的序列化)在下列程序的空白处,应填入的正确选项是________。import java. io.*;public class ObjectStreamTest{ public static void main(String args[]) throws IOException{ ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(serial.bin)); java.util.Date d=new java.util.Date(); oos.______(d); ObjectInputStream ois = new ObjectInputStream (new FileInputStream(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); } }}
- 阅读下列程序,请写出该程序的功能。 import java. util.*; public class Class1{ public static void main(Srting args[]){ Date date1=new Date(); System. out. println (datel); String t=datel.toString(); int endPos=t.indexOf(`C'); t=t.substring(11,endPos); System. out println(t); } }