我要在我文档中检查aa.xml文件是否存在,如果不存在则产生一个,请问如何做?
请大家指点.

解决方案 »

  1.   

    File file = new File("c:\\aa.xml");
    if (!file.exists()) {
    file.createNewFile();
    }
      

  2.   

    public class Tfile {    public static void main(String[] args) {
            File f = new File("c:/aa.xml");
            if(f.exists()){
                
            }
            else{
                //这里你自己发挥了
            }
                
        }
    }