原程序代码:
package edu.jmi.test;import   java.lang.reflect.Method; 
import   java.io.*; 
import   java.lang.*; 
import   java.text.*;  public   class   ifHaveFile   

        public   static   void   main(String   args[]) 
        { 
        StringBuffer   fileBuf=new   StringBuffer(); 
        String   filePar   =   "e:\\test "; 
        System.out.println(filePar);
        File   myPath   =   new   File(filePar); 
        System.out.println(myPath);
                if   (!myPath.exists())//若此目录不存在,则创建之 
                {
                
                
                       myPath.mkdir(); 
                       
                      // System.out.println(myPath.mkdir());
                }       
                String filename  =  "test.txt "; 
                File   logFile = new File(myPath,filename); 
                System.out.println(logFile.getAbsolutePath());
                if   (!logFile.exists()) 
                
                { 
                
                 //System.out.println(logFile.exists());
                System.out.println( "this   file   not   exists! "); 
                //给文件追加内容! 
                                fileBuf.append( "this   is   only   a   test!!! "); 
                                try 
                                { 
                                //创建新文件 
                                RandomAccessFile   files   =   new   RandomAccessFile(logFile,"rw"); 
                                      try 
                                                { 
                                                //给文件添加内容 
                                                files.writeBytes(fileBuf.toString()); 
                                                                files.close(); 
                                                } 
                                                catch   (IOException   ioEx) 
                                                { 
                                                System.err.println(ioEx.toString()); 
                                                } 
                                } 
                                catch   (   FileNotFoundException   fouEx) 
                                { 
                                System.err.println(fouEx.toString()); 
                                } 
                } 
                else 
                { 
                System.out.println( "this   file   exists! "); 
                //如果存在,则在文件原有的内容上添加,既保留文件原有的内容,该如何做???? 
                
                }                       
        } 

运行时候出现的错误:e:\test 
e:\test 
e:\test \test.txt 
this   file   not   exists! 
java.io.FileNotFoundException: e:\test \test.txt  (系统找不到指定的路径。)