Java file operations Daquan 8: how to write additional data to a file

  Abstract: Java file operations Daquan 8: how to write additional data to a file 

  </ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> <table width="731" border="0"> <tr> <td width = " 725 "> </ td> </ tr> </ table> 
  <% @ Page contentType = "text / html; gb2312 charset ="%> 
  <% @ Page import = "java.io. *"%> 

<head>

  </ Head> 
<body>
<%
  String path = request.getRealPath ( "/ article/article5a/example/filetest"); 
  RandomAccessFile rf = new RandomAccessFile (path + "\ \ WriteData.txt", "rw"); 
  / / Define a category RandomAccessFile targets, and examples of 
  Rf.seek (rf.length ());// mobile pointer at the end of the document 
  Rf.writeBytes ( "\ nAppend a line to the file!"); 
  Rf.close ();// close the document flow 
  Out.println ( "writes the document says: 
");
  FileReader fr = new FileReader (path + "\ \ WriteData.txt"); 
  BufferedReader br = new BufferedReader (fr); / / read the document object BufferedRead 
  String Line = br.readLine (); 
  While (Line! = Null) ( 
  Out.println (Line + " 
");
  Line = br.readLine (); 
  ) 
  Fr.close ();// closing documents 
%>
  </ Body> 
  </ Td> </ tr> <tr> 

  ↑ Back 

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • DotNetKicks
  • DZone
  • Netvouz
  • Propeller

Tags: ,

Releated Java Articles

Comments

Leave a Reply