按注释提示完成文件复制的程序//FileStream源代码如下:import java.io.*;class FileStream {public static void main(String args []) {try {File inFile = new File("file1.txt"); //指定源文件File outFile = new File("file2.txt"); //指定目标文件FileInputStream fis =();FileOutputStream fos = new FileOutputStream(outFile);int c;//逐字节从源文件中输入,再输出到fos流while ((c = fis.read ())!=-1)();fis.close();fos.close();}catch (Exception e) {System.out.println("FileStreamsTest: "+e);}}}
查看答案
完成代码计算10的阶乘并输出,把下面代码补全:int result = 1;for(int i = 2; i <= 10; i++){}System.out.println(“result=”+ result);
//把几个JAVA类型的数据写到一个文件,并读取出来。importjava.io.*;publicclassDataInAndOutStream{publicstaticvoidmain(String args[]){try{ FileOutputStream fos=newFileOutputStream("DataOut.dat");(1)out_data.writeInt(156);out_data.writeLong(987654L);out_data.writeFloat(3.14f);out_data.writeDouble(92521.14);out_data.writeBoolean(true);out_data.writeUTF("JAVA语言真奇妙!");out_data.writeByte(123);out_data.writeChars("I am ok");}catch(IOException e){}try{ (2)DataInputStream in_data=newDataInputStream(fis);(3)//读取long整数System.out.println(":"+in_data.readLong());//读取第1个float数System.out.println(":"+in_data.readFloat());//读取第1个double数System.out.println(":"+_(4) );//读取第1个boolean值System.out.println(":"+in_data.readBoolean());//读取第1个UTF值System.out.println(":"+in_data.readUTF());//读取第1个Byte数System.out.println(":"+in_data.readByte());charc;while((5)_) //'\0'表示空字符System.out.print(c);}catch(IOException e){}}}
写出下列程序段的运行结果public class Test{public static void main(String[]args){int x;int a[]={0,0,0,0,0,0};calculate(a,a[5]);System.out.println("the value of a[0] is "+a[0]);System.out.println("the value is a[5] is "+a[5]);}static int calculate(int x[],int y){for(int i=1;i
写出下列程序段的运行结果classA{doublef(doublex,doubley){returnx*y;}}classBextendsA{doublef(doublex,doubley){returnx+y;}}publicclassTest{publicstaticvoidmain(Stringargs[]){Bobj=newB();System.out.println("Theprogramoutputis"+obj.f(4,6));}}