﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-我的java生涯-随笔分类-java文件操作</title><link>http://www.blogjava.net/senlin-blog/category/27416.html</link><description /><language>zh-cn</language><lastBuildDate>Wed, 26 Mar 2008 14:41:58 GMT</lastBuildDate><pubDate>Wed, 26 Mar 2008 14:41:58 GMT</pubDate><ttl>60</ttl><item><title>解决RandomAccessFile写入文件乱码的办法</title><link>http://www.blogjava.net/senlin-blog/archive/2008/03/26/188739.html</link><dc:creator>我的java生涯</dc:creator><author>我的java生涯</author><pubDate>Wed, 26 Mar 2008 06:19:00 GMT</pubDate><guid>http://www.blogjava.net/senlin-blog/archive/2008/03/26/188739.html</guid><wfw:comment>http://www.blogjava.net/senlin-blog/comments/188739.html</wfw:comment><comments>http://www.blogjava.net/senlin-blog/archive/2008/03/26/188739.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.blogjava.net/senlin-blog/comments/commentRss/188739.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/senlin-blog/services/trackbacks/188739.html</trackback:ping><description><![CDATA[
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img id="Codehighlighter1_4_247_Open_Image" onclick="this.style.display='none'; Codehighlighter1_4_247_Open_Text.style.display='none'; Codehighlighter1_4_247_Closed_Image.style.display='inline'; Codehighlighter1_4_247_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" />
				<img id="Codehighlighter1_4_247_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_4_247_Closed_Text.style.display='none'; Codehighlighter1_4_247_Open_Image.style.display='inline'; Codehighlighter1_4_247_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align="top" />
				<span style="COLOR: #0000ff">try</span>
				<span style="COLOR: #000000"> </span>
				<span id="Codehighlighter1_4_247_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.blogjava.net/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_4_247_Open_Text">
						<span style="COLOR: #000000">{                       RandomAccessFile out</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #0000ff">new</span>
						<span style="COLOR: #000000"> RandomAccessFile(file,</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">rw</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">);             <br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />out.seek(out.length());</span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000">将指针移动到文件末尾</span>
						<span style="COLOR: #008000">
								<br />
								<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />
						</span>
						<span style="COLOR: #000000">out.writeBytes(</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">\r\n</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />mess </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">写入文件</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" /></span>
						<span style="COLOR: #0000ff">byte</span>
						<span style="COLOR: #000000"> buffer[] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">new</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">byte</span>
						<span style="COLOR: #000000">[</span>
						<span style="COLOR: #000000">1024</span>
						<span style="COLOR: #000000">];<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />buffer </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> mess.getBytes();<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />out.write(buffer); <br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />out.close();</span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000">关闭文件流 </span>
						<span style="COLOR: #008000">
								<br />
								<img id="Codehighlighter1_271_296_Open_Image" onclick="this.style.display='none'; Codehighlighter1_271_296_Open_Text.style.display='none'; Codehighlighter1_271_296_Closed_Image.style.display='inline'; Codehighlighter1_271_296_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" />
								<img id="Codehighlighter1_271_296_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_271_296_Closed_Text.style.display='none'; Codehighlighter1_271_296_Open_Image.style.display='inline'; Codehighlighter1_271_296_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align="top" />
						</span>
						<span style="COLOR: #000000">}</span>
				</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">catch</span>
				<span style="COLOR: #000000"> (IOException e) </span>
				<span id="Codehighlighter1_271_296_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.blogjava.net/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_271_296_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />  e.printStackTrace();<br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
		</div>
<img src ="http://www.blogjava.net/senlin-blog/aggbug/188739.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/senlin-blog/" target="_blank">我的java生涯</a> 2008-03-26 14:19 <a href="http://www.blogjava.net/senlin-blog/archive/2008/03/26/188739.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>读取指定的文件并转成字符串</title><link>http://www.blogjava.net/senlin-blog/archive/2007/11/19/161630.html</link><dc:creator>我的java生涯</dc:creator><author>我的java生涯</author><pubDate>Mon, 19 Nov 2007 07:26:00 GMT</pubDate><guid>http://www.blogjava.net/senlin-blog/archive/2007/11/19/161630.html</guid><wfw:comment>http://www.blogjava.net/senlin-blog/comments/161630.html</wfw:comment><comments>http://www.blogjava.net/senlin-blog/archive/2007/11/19/161630.html#Feedback</comments><slash:comments>7</slash:comments><wfw:commentRss>http://www.blogjava.net/senlin-blog/comments/commentRss/161630.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/senlin-blog/services/trackbacks/161630.html</trackback:ping><description><![CDATA[
		<p> </p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #000000"> InputStream filein </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> FileInputStream(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">C://1.txt</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> OutputStream output </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> response.getOutputStream();</span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">得到输出流</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000"> BufferedOutputStream bos</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> BufferedOutputStream(output);</span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">输出缓冲流       </span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000"> BufferedInputStream bis</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> BufferedInputStream(filein);</span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">输入缓冲流</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">byte</span>
				<span style="COLOR: #000000"> data[]</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">byte</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">4096</span>
				<span style="COLOR: #000000">];</span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">缓冲字节数    </span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> size</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">;     <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> size</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">bis.read(data);    <br /><img id="Codehighlighter1_358_422_Open_Image" onclick="this.style.display='none'; Codehighlighter1_358_422_Open_Text.style.display='none'; Codehighlighter1_358_422_Closed_Image.style.display='inline'; Codehighlighter1_358_422_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_358_422_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_358_422_Closed_Text.style.display='none'; Codehighlighter1_358_422_Open_Image.style.display='inline'; Codehighlighter1_358_422_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align="top" /> </span>
				<span style="COLOR: #0000ff">while</span>
				<span style="COLOR: #000000"> (size</span>
				<span style="COLOR: #000000">!=-</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">)    </span>
				<span id="Codehighlighter1_358_422_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.blogjava.net/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_358_422_Open_Text">
						<span style="COLOR: #000000">{  <br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />  bos.write(data,</span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">,size);      <br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />  size</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">bis.read(data);   <br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />  }</span>
				</span>
				<span style="COLOR: #000000">   <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> bis.close();  <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> bos.flush();</span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">清空输出缓冲流   </span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000"> bos.close();   <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    output.close();           <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> filein.close();</span>
		</div>
<img src ="http://www.blogjava.net/senlin-blog/aggbug/161630.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/senlin-blog/" target="_blank">我的java生涯</a> 2007-11-19 15:26 <a href="http://www.blogjava.net/senlin-blog/archive/2007/11/19/161630.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java读写删.text,.xml文件内容</title><link>http://www.blogjava.net/senlin-blog/archive/2007/08/15/136921.html</link><dc:creator>我的java生涯</dc:creator><author>我的java生涯</author><pubDate>Wed, 15 Aug 2007 07:10:00 GMT</pubDate><guid>http://www.blogjava.net/senlin-blog/archive/2007/08/15/136921.html</guid><wfw:comment>http://www.blogjava.net/senlin-blog/comments/136921.html</wfw:comment><comments>http://www.blogjava.net/senlin-blog/archive/2007/08/15/136921.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/senlin-blog/comments/commentRss/136921.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/senlin-blog/services/trackbacks/136921.html</trackback:ping><description><![CDATA[
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #008080"> 1</span>
				<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #0000ff">package</span>
				<span style="COLOR: #000000"> com.paiao.bdpm.flow.base;<br /></span>
				<span style="COLOR: #008080"> 2</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080"> 3</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> java.io.BufferedReader;<br /></span>
				<span style="COLOR: #008080"> 4</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> java.io.BufferedWriter;<br /></span>
				<span style="COLOR: #008080"> 5</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> java.io.File;<br /></span>
				<span style="COLOR: #008080"> 6</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> java.io.FileReader;<br /></span>
				<span style="COLOR: #008080"> 7</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> java.io.FileWriter;<br /></span>
				<span style="COLOR: #008080"> 8</span>
				<span style="COLOR: #000000">
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080"> 9</span>
				<span style="COLOR: #000000">
						<img id="Codehighlighter1_199_1765_Open_Image" onclick="this.style.display='none'; Codehighlighter1_199_1765_Open_Text.style.display='none'; Codehighlighter1_199_1765_Closed_Image.style.display='inline'; Codehighlighter1_199_1765_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" />
						<img id="Codehighlighter1_199_1765_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_199_1765_Closed_Text.style.display='none'; Codehighlighter1_199_1765_Open_Image.style.display='inline'; Codehighlighter1_199_1765_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">class</span>
				<span style="COLOR: #000000"> ReadTextFile </span>
				<span id="Codehighlighter1_199_1765_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.blogjava.net/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_199_1765_Open_Text">
						<span style="COLOR: #000000">{<br /></span>
						<span style="COLOR: #008080">10</span>
						<span style="COLOR: #000000">
								<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">public</span>
						<span style="COLOR: #000000"> BufferedReader bufread;<br /></span>
						<span style="COLOR: #008080">11</span>
						<span style="COLOR: #000000">
								<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">public</span>
						<span style="COLOR: #000000"> BufferedWriter bufwriter;<br /></span>
						<span style="COLOR: #008080">12</span>
						<span style="COLOR: #000000">
								<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />    File writefile;<br /></span>
						<span style="COLOR: #008080">13</span>
						<span style="COLOR: #000000">
								<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />    String filepath, filecontent, read;<br /></span>
						<span style="COLOR: #008080">14</span>
						<span style="COLOR: #000000">
								<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />    String readStr </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">""</span>
						<span style="COLOR: #000000">;<br /></span>
						<span style="COLOR: #008080">15</span>
						<span style="COLOR: #000000">
								<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000">从文本文件中读取内容</span>
						<span style="COLOR: #008000">
								<br />
						</span>
						<span style="COLOR: #008080">16</span>
						<span style="COLOR: #008000">
								<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />
						</span>
						<span style="COLOR: #000000">    </span>
						<span style="COLOR: #0000ff">public</span>
						<span style="COLOR: #000000"> String readfile(String path)   <br /></span>
						<span style="COLOR: #008080">17</span>
						<span style="COLOR: #000000">
								<img id="Codehighlighter1_401_784_Open_Image" onclick="this.style.display='none'; Codehighlighter1_401_784_Open_Text.style.display='none'; Codehighlighter1_401_784_Closed_Image.style.display='inline'; Codehighlighter1_401_784_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_401_784_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_401_784_Closed_Text.style.display='none'; Codehighlighter1_401_784_Open_Image.style.display='inline'; Codehighlighter1_401_784_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_401_784_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.blogjava.net/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_401_784_Open_Text">
								<span style="COLOR: #000000">{<br /></span>
								<span style="COLOR: #008080">18</span>
								<span style="COLOR: #000000">
										<img id="Codehighlighter1_409_683_Open_Image" onclick="this.style.display='none'; Codehighlighter1_409_683_Open_Text.style.display='none'; Codehighlighter1_409_683_Closed_Image.style.display='inline'; Codehighlighter1_409_683_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
										<img id="Codehighlighter1_409_683_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_409_683_Closed_Text.style.display='none'; Codehighlighter1_409_683_Open_Image.style.display='inline'; Codehighlighter1_409_683_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">try</span>
								<span style="COLOR: #000000"> </span>
								<span id="Codehighlighter1_409_683_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
										<img src="http://www.blogjava.net/images/dot.gif" />
								</span>
								<span id="Codehighlighter1_409_683_Open_Text">
										<span style="COLOR: #000000">{<br /></span>
										<span style="COLOR: #008080">19</span>
										<span style="COLOR: #000000">
												<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />            filepath </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> path; </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000">得到文本文件的路径</span>
										<span style="COLOR: #008000">
												<br />
										</span>
										<span style="COLOR: #008080">20</span>
										<span style="COLOR: #008000">
												<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />
										</span>
										<span style="COLOR: #000000">            File file </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #0000ff">new</span>
										<span style="COLOR: #000000"> File(filepath);<br /></span>
										<span style="COLOR: #008080">21</span>
										<span style="COLOR: #000000">
												<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />            FileReader fileread </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #0000ff">new</span>
										<span style="COLOR: #000000"> FileReader(file);<br /></span>
										<span style="COLOR: #008080">22</span>
										<span style="COLOR: #000000">
												<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />            bufread </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #0000ff">new</span>
										<span style="COLOR: #000000"> BufferedReader(fileread);<br /></span>
										<span style="COLOR: #008080">23</span>
										<span style="COLOR: #000000">
												<img id="Codehighlighter1_615_679_Open_Image" onclick="this.style.display='none'; Codehighlighter1_615_679_Open_Text.style.display='none'; Codehighlighter1_615_679_Closed_Image.style.display='inline'; Codehighlighter1_615_679_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
												<img id="Codehighlighter1_615_679_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_615_679_Closed_Text.style.display='none'; Codehighlighter1_615_679_Open_Image.style.display='inline'; Codehighlighter1_615_679_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">while</span>
										<span style="COLOR: #000000"> ((read </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> bufread.readLine()) </span>
										<span style="COLOR: #000000">!=</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #0000ff">null</span>
										<span style="COLOR: #000000">) </span>
										<span id="Codehighlighter1_615_679_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
												<img src="http://www.blogjava.net/images/dot.gif" />
										</span>
										<span id="Codehighlighter1_615_679_Open_Text">
												<span style="COLOR: #000000">{<br /></span>
												<span style="COLOR: #008080">24</span>
												<span style="COLOR: #000000">
														<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />                read </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> read</span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000">"</span>
												<span style="COLOR: #000000">\r\n</span>
												<span style="COLOR: #000000">"</span>
												<span style="COLOR: #000000">;            <br /></span>
												<span style="COLOR: #008080">25</span>
												<span style="COLOR: #000000">
														<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />                readStr </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> readStr </span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000"> read;<br /></span>
												<span style="COLOR: #008080">26</span>
												<span style="COLOR: #000000">
														<img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            }</span>
										</span>
										<span style="COLOR: #000000">
												<br />
										</span>
										<span style="COLOR: #008080">27</span>
										<span style="COLOR: #000000">
												<img id="Codehighlighter1_705_748_Open_Image" onclick="this.style.display='none'; Codehighlighter1_705_748_Open_Text.style.display='none'; Codehighlighter1_705_748_Closed_Image.style.display='inline'; Codehighlighter1_705_748_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
												<img id="Codehighlighter1_705_748_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_705_748_Closed_Text.style.display='none'; Codehighlighter1_705_748_Open_Image.style.display='inline'; Codehighlighter1_705_748_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #0000ff">catch</span>
								<span style="COLOR: #000000"> (Exception d) </span>
								<span id="Codehighlighter1_705_748_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
										<img src="http://www.blogjava.net/images/dot.gif" />
								</span>
								<span id="Codehighlighter1_705_748_Open_Text">
										<span style="COLOR: #000000">{<br /></span>
										<span style="COLOR: #008080">28</span>
										<span style="COLOR: #000000">
												<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />            System.out.println(d.getMessage());<br /></span>
										<span style="COLOR: #008080">29</span>
										<span style="COLOR: #000000">
												<img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
								</span>
								<span style="COLOR: #008080">30</span>
								<span style="COLOR: #000000">
										<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">return</span>
								<span style="COLOR: #000000"> readStr; </span>
								<span style="COLOR: #008000">//</span>
								<span style="COLOR: #008000">返回从文本文件中读取内容</span>
								<span style="COLOR: #008000">
										<br />
								</span>
								<span style="COLOR: #008080">31</span>
								<span style="COLOR: #008000">
										<img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />
								</span>
								<span style="COLOR: #000000">    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
						</span>
						<span style="COLOR: #008080">32</span>
						<span style="COLOR: #000000">
								<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />
								<br />
						</span>
						<span style="COLOR: #008080">33</span>
						<span style="COLOR: #000000">
								<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000">向文本文件中写入内容</span>
						<span style="COLOR: #008000">
								<br />
						</span>
						<span style="COLOR: #008080">34</span>
						<span style="COLOR: #008000">
								<img id="Codehighlighter1_869_1519_Open_Image" onclick="this.style.display='none'; Codehighlighter1_869_1519_Open_Text.style.display='none'; Codehighlighter1_869_1519_Closed_Image.style.display='inline'; Codehighlighter1_869_1519_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_869_1519_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_869_1519_Closed_Text.style.display='none'; Codehighlighter1_869_1519_Open_Image.style.display='inline'; Codehighlighter1_869_1519_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />
						</span>
						<span style="COLOR: #000000">    </span>
						<span style="COLOR: #0000ff">public</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">void</span>
						<span style="COLOR: #000000"> writefile(String path, String content, </span>
						<span style="COLOR: #0000ff">boolean</span>
						<span style="COLOR: #000000"> append) </span>
						<span id="Codehighlighter1_869_1519_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.blogjava.net/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_869_1519_Open_Text">
								<span style="COLOR: #000000">{<br /></span>
								<span style="COLOR: #008080">35</span>
								<span style="COLOR: #000000">
										<img id="Codehighlighter1_877_1451_Open_Image" onclick="this.style.display='none'; Codehighlighter1_877_1451_Open_Text.style.display='none'; Codehighlighter1_877_1451_Closed_Image.style.display='inline'; Codehighlighter1_877_1451_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
										<img id="Codehighlighter1_877_1451_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_877_1451_Closed_Text.style.display='none'; Codehighlighter1_877_1451_Open_Image.style.display='inline'; Codehighlighter1_877_1451_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">try</span>
								<span style="COLOR: #000000"> </span>
								<span id="Codehighlighter1_877_1451_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
										<img src="http://www.blogjava.net/images/dot.gif" />
								</span>
								<span id="Codehighlighter1_877_1451_Open_Text">
										<span style="COLOR: #000000">{<br /></span>
										<span style="COLOR: #008080">36</span>
										<span style="COLOR: #000000">
												<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">boolean</span>
										<span style="COLOR: #000000"> addStr </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> append; </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000">通过这个对象来判断是否向文本文件中追加内容</span>
										<span style="COLOR: #008000">
												<br />
										</span>
										<span style="COLOR: #008080">37</span>
										<span style="COLOR: #008000">
												<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />
										</span>
										<span style="COLOR: #000000">            filepath </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> path; </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000">得到文本文件的路径</span>
										<span style="COLOR: #008000">
												<br />
										</span>
										<span style="COLOR: #008080">38</span>
										<span style="COLOR: #008000">
												<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />
										</span>
										<span style="COLOR: #000000">            filecontent </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> content; </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000">需要写入的内容</span>
										<span style="COLOR: #008000">
												<br />
										</span>
										<span style="COLOR: #008080">39</span>
										<span style="COLOR: #008000">
												<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />
										</span>
										<span style="COLOR: #000000">            writefile </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #0000ff">new</span>
										<span style="COLOR: #000000"> File(filepath);<br /></span>
										<span style="COLOR: #008080">40</span>
										<span style="COLOR: #000000">
												<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">if</span>
										<span style="COLOR: #000000"> (writefile.exists() </span>
										<span style="COLOR: #000000">==</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #0000ff">false</span>
										<span style="COLOR: #000000">) </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000">如果文本文件不存在则创建它 </span>
										<span style="COLOR: #008000">
												<br />
										</span>
										<span style="COLOR: #008080">41</span>
										<span style="COLOR: #008000">
												<img id="Codehighlighter1_1090_1170_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1090_1170_Open_Text.style.display='none'; Codehighlighter1_1090_1170_Closed_Image.style.display='inline'; Codehighlighter1_1090_1170_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
												<img id="Codehighlighter1_1090_1170_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1090_1170_Closed_Text.style.display='none'; Codehighlighter1_1090_1170_Open_Image.style.display='inline'; Codehighlighter1_1090_1170_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />
										</span>
										<span style="COLOR: #000000">            </span>
										<span id="Codehighlighter1_1090_1170_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
												<img src="http://www.blogjava.net/images/dot.gif" />
										</span>
										<span id="Codehighlighter1_1090_1170_Open_Text">
												<span style="COLOR: #000000">{<br /></span>
												<span style="COLOR: #008080">42</span>
												<span style="COLOR: #000000">
														<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />                writefile.createNewFile();<br /></span>
												<span style="COLOR: #008080">43</span>
												<span style="COLOR: #000000">
														<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />                writefile </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #0000ff">new</span>
												<span style="COLOR: #000000"> File(filepath); </span>
												<span style="COLOR: #008000">//</span>
												<span style="COLOR: #008000">重新实例化</span>
												<span style="COLOR: #008000">
														<br />
												</span>
												<span style="COLOR: #008080">44</span>
												<span style="COLOR: #008000">
														<img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />
												</span>
												<span style="COLOR: #000000">            }</span>
										</span>
										<span style="COLOR: #000000">
												<br />
										</span>
										<span style="COLOR: #008080">45</span>
										<span style="COLOR: #000000">
												<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />            FileWriter filewriter </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #0000ff">new</span>
										<span style="COLOR: #000000"> FileWriter(writefile, addStr);<br /></span>
										<span style="COLOR: #008080">46</span>
										<span style="COLOR: #000000">
												<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000">删除原有文件的内容</span>
										<span style="COLOR: #008000">
												<br />
										</span>
										<span style="COLOR: #008080">47</span>
										<span style="COLOR: #008000">
												<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />
										</span>
										<span style="COLOR: #000000">            java.io.RandomAccessFile file</span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #0000ff">new</span>
										<span style="COLOR: #000000"> java.io.RandomAccessFile(path,</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">rw</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">);<br /></span>
										<span style="COLOR: #008080">48</span>
										<span style="COLOR: #000000">
												<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />            file.setLength(</span>
										<span style="COLOR: #000000">0</span>
										<span style="COLOR: #000000">);<br /></span>
										<span style="COLOR: #008080">49</span>
										<span style="COLOR: #000000">
												<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000">写入新的文件内容</span>
										<span style="COLOR: #008000">
												<br />
										</span>
										<span style="COLOR: #008080">50</span>
										<span style="COLOR: #008000">
												<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />
										</span>
										<span style="COLOR: #000000">            filewriter.write(filecontent);<br /></span>
										<span style="COLOR: #008080">51</span>
										<span style="COLOR: #000000">
												<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />            filewriter.close();<br /></span>
										<span style="COLOR: #008080">52</span>
										<span style="COLOR: #000000">
												<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />            filewriter.flush();<br /></span>
										<span style="COLOR: #008080">53</span>
										<span style="COLOR: #000000">
												<img id="Codehighlighter1_1473_1516_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1473_1516_Open_Text.style.display='none'; Codehighlighter1_1473_1516_Closed_Image.style.display='inline'; Codehighlighter1_1473_1516_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
												<img id="Codehighlighter1_1473_1516_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1473_1516_Closed_Text.style.display='none'; Codehighlighter1_1473_1516_Open_Image.style.display='inline'; Codehighlighter1_1473_1516_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #0000ff">catch</span>
								<span style="COLOR: #000000"> (Exception d) </span>
								<span id="Codehighlighter1_1473_1516_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
										<img src="http://www.blogjava.net/images/dot.gif" />
								</span>
								<span id="Codehighlighter1_1473_1516_Open_Text">
										<span style="COLOR: #000000">{<br /></span>
										<span style="COLOR: #008080">54</span>
										<span style="COLOR: #000000">
												<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />            System.out.println(d.getMessage());<br /></span>
										<span style="COLOR: #008080">55</span>
										<span style="COLOR: #000000">
												<img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
								</span>
								<span style="COLOR: #008080">56</span>
								<span style="COLOR: #000000">
										<img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
						</span>
						<span style="COLOR: #008080">57</span>
						<span style="COLOR: #000000">
								<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />
								<br />
						</span>
						<span style="COLOR: #008080">58</span>
						<span style="COLOR: #000000">
								<img id="Codehighlighter1_1579_1763_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1579_1763_Open_Text.style.display='none'; Codehighlighter1_1579_1763_Closed_Image.style.display='inline'; Codehighlighter1_1579_1763_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_1579_1763_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1579_1763_Closed_Text.style.display='none'; Codehighlighter1_1579_1763_Open_Image.style.display='inline'; Codehighlighter1_1579_1763_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">public</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">static</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">void</span>
						<span style="COLOR: #000000"> main(String[] args) </span>
						<span style="COLOR: #0000ff">throws</span>
						<span style="COLOR: #000000"> Exception </span>
						<span id="Codehighlighter1_1579_1763_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.blogjava.net/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_1579_1763_Open_Text">
								<span style="COLOR: #000000">{<br /></span>
								<span style="COLOR: #008080">59</span>
								<span style="COLOR: #000000">
										<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        ReadTextFile parse </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #0000ff">new</span>
								<span style="COLOR: #000000"> ReadTextFile();<br /></span>
								<span style="COLOR: #008080">60</span>
								<span style="COLOR: #000000">
										<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        String filecontent </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> parse.readfile(</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">c:/applicationContext.xml</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">);        <br /></span>
								<span style="COLOR: #008080">61</span>
								<span style="COLOR: #000000">
										<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        parse.writefile(</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">c:/applicationContext.xml</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">,filecontent,</span>
								<span style="COLOR: #0000ff">true</span>
								<span style="COLOR: #000000">);<br /></span>
								<span style="COLOR: #008080">62</span>
								<span style="COLOR: #000000">
										<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        <br /></span>
								<span style="COLOR: #008080">63</span>
								<span style="COLOR: #000000">
										<img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
						</span>
						<span style="COLOR: #008080">64</span>
						<span style="COLOR: #000000">
								<img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
		</div>
<img src ="http://www.blogjava.net/senlin-blog/aggbug/136921.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/senlin-blog/" target="_blank">我的java生涯</a> 2007-08-15 15:10 <a href="http://www.blogjava.net/senlin-blog/archive/2007/08/15/136921.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>拷贝一个文件到另一个地方</title><link>http://www.blogjava.net/senlin-blog/archive/2007/03/25/106155.html</link><dc:creator>我的java生涯</dc:creator><author>我的java生涯</author><pubDate>Sat, 24 Mar 2007 16:33:00 GMT</pubDate><guid>http://www.blogjava.net/senlin-blog/archive/2007/03/25/106155.html</guid><wfw:comment>http://www.blogjava.net/senlin-blog/comments/106155.html</wfw:comment><comments>http://www.blogjava.net/senlin-blog/archive/2007/03/25/106155.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/senlin-blog/comments/commentRss/106155.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/senlin-blog/services/trackbacks/106155.html</trackback:ping><description><![CDATA[
		<p>package codemaking.util;</p>
		<p>import java.awt.*;<br />import java.io.*;<br />/**<br />* @author Administrator<br />*<br />* Class Function:<br />*/<br />public class copyDirectory {<br />public static void main(String args[]) throws IOException {<br />String url1="D:/download";<br />String url2="f:/download";<br />(new File(url2)).mkdirs();<br />File[] file=(new File(url1)).listFiles();<br />for(int i=0;i&lt;file.length;i++){<br />if(file[i].isFile()){<br /> FileInputStream input=new FileInputStream(file[i]);<br /> FileOutputStream output=new FileOutputStream(url2+"/"+file[i].getName());<br /> byte[] b=new byte[1024*5];<br />  int len;<br />  while((len=input.read(b))!=-1){<br />  output.write(b,0,len);<br />  }<br />  output.flush();<br />  output.close();<br />  input.close();<br />  }<br />if(file[i].isDirectory()){<br /> copyDirectiory(url2+"/"+file[i].getName(),url1+"/"+file[i].getName());<br /> }<br />}<br />}</p>
		<p>
				<br />public static void copyDirectiory(String file1,String file2) throws IOException{<br />(new File(file1)).mkdirs();<br />File[] file=(new File(file2)).listFiles();<br />for(int i=0;i&lt;file.length;i++){<br /> if(file[i].isFile()){<br /> FileInputStream input=new FileInputStream(file[i]);<br /> FileOutputStream output=new FileOutputStream(file1+"/"+file[i].getName());<br /> byte[] b=new byte[1024*5];<br />   int len;<br />   while((len=input.read(b))!=-1){<br />    output.write(b,0,len);<br />    }<br />    output.flush();<br />       output.close();<br />    input.close();<br />   }<br /> if(file[i].isDirectory()){<br />  copyDirectiory(file1+"/"+file[i].getName(),file2+"/"+file[i].getName());<br />}</p>
		<p>}</p>
		<p>}<br />}<br /></p>
<img src ="http://www.blogjava.net/senlin-blog/aggbug/106155.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/senlin-blog/" target="_blank">我的java生涯</a> 2007-03-25 00:33 <a href="http://www.blogjava.net/senlin-blog/archive/2007/03/25/106155.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>