读写文件
来源:互联网 发布:银龙知识产权 知乎 编辑:程序博客网 时间:2024/05/17 08:59
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--> 1 ////////////////////////////////////////////////////////////////
2 //
3 // 程序:ReadWiteFile.java
4 //
5 // 描述:对文件读写操作
6 //
7 // 作者:JAVA-HE
8 //
9 // 时间:2006-12-20
10 //
11 //////////////////////////////////////////////////////////////
12
13 package com.readwritefile;
14
15 import java.io.*;
16 public class ReadWiteFile
17 {
18 public ReadWiteFile ()
19 {
20 }
21 public static void main(String args [])
22 {
23 ReadWiteFile managerFile = new ReadWiteFile();
24 File readfile = new File("read.txt");
25 File writefile = new File("write.txt");
26 String content = "";
27 try
28 {
29 content = managerFile.readFile(readfile);
30
31 }catch(Exception ex)
32 {
33 System.out.println ("读文件发生异常:"+ex.toString ());
34 }
35 try
36 {
37 managerFile.writeFile(writefile,content);
38 }catch(Exception e)
39 {
40 System.out.println ("写文件发生异常:"+e.toString ());
41 }
42 }
43 private String readFile (File readfile) throws Exception
44 {
45 FileReader read = new FileReader(readfile);
46 BufferedReader in = new BufferedReader(read);
47 String readResult="";
48 String str = "";
49 while((str=in.readLine ())!= null)
50 {
51 String tem [] = str.split ("=");
52 readResult += "m_objCitys.Add /""+tem[1]+"/", /""+tem[0]+"/""+"/n";
53 }
54 read.close ();
55 in.close ();
56 return readResult;
57 }
58
59 private void writeFile (File writefile, String content) throws Exception
60 {
61 FileWriter write = new FileWriter(writefile);
62 BufferedWriter wr = new BufferedWriter(write);
63 wr.write (content);
64 wr.flush ();
65 wr.close ();
66 write.close ();
67 }
68
69 }
70
71
72
73
74
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--> 1 ////////////////////////////////////////////////////////////////
2 //
3 // 程序:ReadWiteFile.java
4 //
5 // 描述:对文件读写操作
6 //
7 // 作者:JAVA-HE
8 //
9 // 时间:2006-12-20
10 //
11 //////////////////////////////////////////////////////////////
12
13 package com.readwritefile;
14
15 import java.io.*;
16 public class ReadWiteFile
17 {
18 public ReadWiteFile ()
19 {
20 }
21 public static void main(String args [])
22 {
23 ReadWiteFile managerFile = new ReadWiteFile();
24 File readfile = new File("read.txt");
25 File writefile = new File("write.txt");
26 String content = "";
27 try
28 {
29 content = managerFile.readFile(readfile);
30
31 }catch(Exception ex)
32 {
33 System.out.println ("读文件发生异常:"+ex.toString ());
34 }
35 try
36 {
37 managerFile.writeFile(writefile,content);
38 }catch(Exception e)
39 {
40 System.out.println ("写文件发生异常:"+e.toString ());
41 }
42 }
43 private String readFile (File readfile) throws Exception
44 {
45 FileReader read = new FileReader(readfile);
46 BufferedReader in = new BufferedReader(read);
47 String readResult="";
48 String str = "";
49 while((str=in.readLine ())!= null)
50 {
51 String tem [] = str.split ("=");
52 readResult += "m_objCitys.Add /""+tem[1]+"/", /""+tem[0]+"/""+"/n";
53 }
54 read.close ();
55 in.close ();
56 return readResult;
57 }
58
59 private void writeFile (File writefile, String content) throws Exception
60 {
61 FileWriter write = new FileWriter(writefile);
62 BufferedWriter wr = new BufferedWriter(write);
63 wr.write (content);
64 wr.flush ();
65 wr.close ();
66 write.close ();
67 }
68
69 }
70
71
72
73
74
- 文件读写、剪贴板读写
- 读写文件
- 文件读写
- 读写文件
- 读写文件
- 文件读写
- 读写文件
- 读写文件
- 读写文件
- 文件读写
- 文件读写
- 文件读写
- 文件读写
- 读写文件
- 文件读写
- 文件读写
- 文件读写
- 文件读写
- C++基础:常量成员函数特殊说明 - C++技术探讨 - C++博客
- 从函数指针到代理(C#代理入门)
- java
- 正则表达式使用详解
- UNIX 文件系统基本操作
- 读写文件
- Windows消息机制http://www.cnblogs.com/watsonyin/archive/2005/12/12/295536.html
- 在Winfrom下的对DataGridView单元格合并
- 加快客户机和服务器的处理速度
- 李阳疯狂英语突破对话(61)-外出用餐
- Windows消息机制http://blog.csdn.net/weixu_2008/archive/2007/09/15/1785939.aspx
- Squid代理服务器之一基本配置
- 领带打法
- Linux 技巧: 用 cron 和 at 调度作业