请完成下列Java程序:读取自己的源文件并把它压缩成GZIP文件。注意:请勿改动main()主方法和其他已有语句内容,仅在下划线处填入适当的语句。import java.io.*;import java.util.zip.*;public class exl6 2 {public static void main{String[] arg) {ex16_2 obj16_2 = new ex16_2();obj16_2.doZip("ex16_2.java","ex16_2.gzip")}public void doZip(String strIn,String strOutFileInputStream in;FileOutputStream out;GZIPOutputStream gzip;int nFileLength;byte[] barray = new byte[10];try {in = new FileInputStream(strIn);out = new FileOutputStream(strOut);gzip = new GZIPOutputStream(out);while((nFileLength = in.read(barray, 0 barray.length)) > 0)_____________________;______________________;gzip.close();} catch(Exception e) {e.printStackTrace();}}}

请完成下列Java程序:读取自己的源文件并把它压缩成GZIP文件。

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

import java.io.*;

import java.util.zip.*;

public class exl6 2 {

public static void main{String[] arg) {

ex16_2 obj16_2 = new ex16_2();

obj16_2.doZip("ex16_2.java","ex16_2.gzip")

}

public void doZip(String strIn,String strOut

FileInputStream in;

FileOutputStream out;

GZIPOutputStream gzip;

int nFileLength;

byte[] barray = new byte[10];

try {

in = new FileInputStream(strIn);

out = new FileOutputStream(strOut);

gzip = new GZIPOutputStream(out);

while((nFileLength = in.read(barray, 0 barray.length)) > 0)

_____________________;

______________________;

gzip.close();

} catch(Exception e) {

e.printStackTrace();

}

}

}


相关考题:

请完成下列Java程序。程序的功能是利用迭代法求一个数的平方根(求平方根的迭代公式为:Xn+1=1/2(Xn+a/Xn)).注意:请勿改动main()主方法和其他已有的语句内容,仅在下划线处填入适当的语句。public class PingFangGen{public static void main(String args[]){System. out. println(Math, sqrt(2.0));}static double sqrt(______){double x=1.0do{_______}while( Math. abs(x*x-a)/a>le-6)return x;}}

请完成下列Java程序。程序的功能是显示用户在命令行方式下指定的任意驱动器文件夹的内容。提示:public string()list();//将文件夹中所有文件名保存在字符数组中返回。注意:请勿改动main()主方法和其他已有的语句内容,仅在下划线处填入适当的语句。源程序文件代码清单如下:import java.io.*;public class FindDirectories{public static void main(String args[]){if(args.length==0)args=new String(){".."};try{______;String[] fileName=pathName.list();for(int i=0;i<fileName.length;i++){File f=new File(pathName.getPath(),fileName[i]);if(______){System.out.println(f.getCanonicalPath());main(new String[]{f.getPath()});}}}catch(IOException e){e.printStackTrace();}}}

请完成下列Java程序。实例listener是监听器,frm是事件源,fr上发生的事件委托tat进行处理。程序的执行结果是显示一个蓝色的窗口,单击关闭按钮,可关闭窗口。注意:请勿改动main()主方法和其他已有的语句内容,仅在下划线处填入适当的语句。源程序文件代码清单如下:import java.awt.*;import java.awt.event.*;public class BlueWindow{public static void main(String args[]){Frame. frm=new Frame. ("欢迎参加Java考试!");TheAdapterTest listener=new TheAdapterTest();frm. ______;frm.setSize(200,200);frm.setBackground(Color.blue);frm. ______;}}class TheAdapterTest extends WindowAdapter{public void windowClosing(WindowEvent e){System.exit(1);}}

请完成下列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();}}}

请完成下列Java程序。程序的功能是显示用户在命令行方式下指定的任意驱动器目录的内容。(提示:public String[]list();//将目录中所有文件名保存在字符数组中返回)注意:请勿改动main()主方法和其他已有的语句内容,仅在下划线处填入适当的语句。import java.io.*;public class FindDirectories{public static void main(String args[]{if(args.length==0)args=new String[]{".."};try{_______________String[] fileName=pathName.list();for(int i=0;i<fileName.length;i++{File f=new File(pathName.getPath() fileName[i]);if(___________________){System.out.println(f.getCanonicalPath());main(new String[]{f.getPath()});}}}catch(IOException e){e.printStackTrace();}}}

请完成下列Java程序。程序的输出结果:a=6,b=5。注意:请勿改动main()主方法和其他已有语句内容,仅在下划线处填入适当的语句。程序运行结果如下:public class ex38_2{public static void main(String args[]){int a=5,b=6;a=_________;b=a-b;a=_________;System.out.println("a="+a+"\tb="+b);}}

编写函数fun,它的功能是计算下列级数和,和值由函数值返回。例如,当n=10,x=0.3时,函数值为1.349859。注意:部分源程序在文件PROGl.C文件中。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。

请编写一个函数fun,它的功能是:根据以下公式求π的值(要求满足精度0.0005,即某项小于0.0005时停止迭代):程序运行后,如果输入精度0.0005,则程序输出为3.140578。注意:部分源程序存在文件PROGl.C文件中。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。

Java应用程序源文件中最多只能有()个main方法。