- 1、本文档共46页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
输入输出流;1.概述;2.文件(File 类);2.1. 创建文件对象;2.2 查询文件属性;2.3 查询文件属性;3. ;3.1 使用 读取文件;3.2 处理 I/O 异常;3.3 从 中读出;3.4 关闭 ; int b; byte buffer[]=new byte[2500];
try { File(E:\\lanhong\\, a.txt);
read
(f);
b=read(buffer,0,2500);
try { String str=new
String(buffer,0,b,Default);
System.out.println(str);
}catch(UnsupportedEncodingException e)
{ System.out.println(the encoding was not found: +e); }
}catch (IOException e) {
System.out.println( Error); }
Example20_1.java;4. ;4.1 打开 ;4.2 写入一个流 ; public static void main(String args[]) {
int b; byte buffer[]=new byte[100];
try {
System.out.println(输入一行文本,并存入磁盘: );
b=System.in.read(buffer); //把从键盘输入的字符存入buffer
write (line.txt);
write(buffer,0,b); //通过流把buffer 写入到文件line.txt 中
}catch (IOException e) {
System.out.println(Error ); }
} Example20_3.java;5. 和 ;5. 1 BufferedReader;P261, 例4 Example20_4
TextArea text; BufferedReader in; Button button;
file;
EWindow() {
super(流的读取); text=new TextArea(10,10);
text.setBackground(Color.cyan);
try { File(E:\\lanhong\\, a.txt);
(f);
in=new BufferedReader(file);
} catch( e) {}
catch(IOException e) {}
button=new Button(读取);
button.addActionListener(this);; setLayout(new BorderLayout());
setSize(40,40); setVisible(true);
add(text,Center); add(button, South);
addWindowListener( new WindowAdapter() {public void windowClosing(WindowEvent e){System.exit(0);}} ); }
文档评论(0)