请完成下列Java程序。程序的功能是复制文件并显示文件,将每个字符读入,并写入另一个文件,同时显示出来(注意:在本题中,当前目录下的README.txt文件打印在屏幕上,并写入另一个文件temp.txt中)。
注意:请勿改动main()主方法和其他已有的语句内容,仅在下画线处填人适当的语句。
import java.io.*;
public class FileCopyBy{
public static void main(String args[]){
try{
FileReader input=new FileReader("README.txt");
FileWriter utput=new FileWriter("temp.txt");
int c=input.read();
while(__________)
{
__________
System.out.print((char)c);
c=input.read();
}
input.close();
output.close();
}
catch(IOException e)
{
System.out.println(e);
}
}
}
第1题:
以下程序的功能是从名为filea.dat的文本文件中逐个读入字符并显示在屏幕上。请填空。
majn()
{ FILE *fp; char ch;
fp=fopen(______);
ch=fgetc(fp);
whle(!feof(fp)) { putchar(ch); ch=f8etc(fp); }
putchar('\n'); fclose(fp);
}
第2题:
阅读以下程序及对程序功能的描述,其中正确的是 #include<stdio.h> main() { FILE*in,*out; charch,infile[10],outfile[10]; printf("Enter the infile name:\n"); scanf("%s",infile); printf("Enter the outfile name:\n"); scanf("%s",outfile); if((in=foen(infile
A.程序完成将磁盘文件的信息在屏幕上显示的功能
B.程序完成将两个磁盘文件合二为一的功能
C.程序完成将一个磁盘文件复制到另一个磁盘文件中
D.程序完成将两个磁盘文件合并并在屏幕上输出
第3题:
从键盘读入多行文本,并指定文件名,将输入的字符写入到中指定名称的文件中。
第4题:
阅读以下程序以及对程序功能的描述,其中正确的描述是( )。 #include <stdio.h> main() { FILE * in,*out; charch,infile[10],outfile[10]; printf("Enter the infile name:\n"); scanf("%s",infile); printf("Enter the outfile name:\n"); scanf("%s",outfile); if((in=fopen(infile,"r"))==NULL) { printf("cannot open infile\n");exit(0);} if((out=fopen(outfile,"w"))==NULL) { printf("cannot open outfile\n");exit(0); } while(! feof(in)) fputc(fgetc(in),out); fclose(in); fclose(out); }
A.程序完成将磁盘文件的信息在屏幕上显示的功能
B.程序完成将两个磁盘文件合二为一的功能
C.程序完成将一个磁盘文件复制到另一个磁盘文件中的功能
D.程序完成将两个磁盘文件合并并在屏幕上输出的功能
第5题:
阅读以下程序及对程序功能的描述,其中正确的描述是#include <stdio.h>main(){ FILE *in,*out; char ch,infile[10],outfile[10]; printf("Enter the infile name:\n"); scanf("%s",infile); printf("Enter the outfile name:\n"); scanf("%s",outfile); if((in=fopen(infile,"r"))==NULL) { printf("cannot open infile\n"); exit(0); } if((out=fopen(outfile,"w"))==NULL) { printf("cannot open outfile\n"); exit(0); } while(! feof(in))fputc(fgetc(in),out); fclose(in); fclose(out);}A.程序完成将磁盘文件的信息在屏幕上显示的功能B.程序完成将两个磁盘文件合二为一的功能C.程序完成将一个磁盘文件复制到另一个磁盘文件中D.程序完成将两个磁盘文件合并后在屏幕上输出