Java file operations Daquan 1: the establishment of documents, checks and delete

  Abstract: Java file operations Daquan 1: the establishment of documents, checks and delete 

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

<head>

  </ Head> 
<body>
<%
  String path = request.getRealPath ( "/ article/article5a/example/filetest"); 

  Out.println (path + " 
");
  File f = new File (path, "File.txt"); 
  Out.println (f + " 
");
  / / Out.println (f.exists ()); 

  If (f.exists ()){// check whether there File.txt 
  F.delete ();// delete documents File.txt 
  Out.println (path + "\ \ File.txt exist, has been deleted."); 
  Else () 
  F.createNewFile ();// under the current directory creation of a document entitled File.txt 
  Out.println (path + "\ \ File.txt did not exist, the current output has been established 。");// the directory path 
  ) 
%>
  </ Td> <td width="264" valign="top" class="ArticleTeitle"> 
  </ Td> </ tr> <tr> <td height="25" colspan="2" valign="top" class="ArticleTeitle"> 

  ↑ 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