设为首页 加入收藏

TOP

中兴公司计算机专业应届生笔试试卷(04)(二)
2014-11-23 21:26:42 来源: 作者: 【 】 浏览:29
Tags:中兴 公司 计算机 专业 应届 笔试 试卷
× ×
不写时默认为friendly




7. 写个程序,要求创建一个文件,写入从键盘输入的一串字符,然后再读该文件并将文件内容显示在屏幕上。(18分)


import java.io.*;


class MyFileIo{


public static void main(String args[]){


FileInputStream fin;


FileOutputStream fout;


char ch;


int data;


try{


fin = new FileInputStream(FileDescriptor.in);


fout = new FileOutputStream(“myfile1”);


System.out.println(“请输入一串字符以#结束:”);


while((ch = (char)fin.read()) != ‘#’)


Fout.write(ch);


fin.close();


fou.close();


System.out.print(“”);


fin = new FileInputStream(“myfile1”);


fout = new FileOutpurStream(FileDescriptor.out);


while(fin.available() > 0){


data = fin.read();


fou.write(data);


}


fin.close();


fout.close();


}catch(FileNotFoundException e){


System.out.println(“File not found!”);


}carch(IOException e){}


}


}




首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇如何开始一个Struts项目 下一篇操作系统笔试题及答案(5)

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: