创建文件时,不可以含有目录,只能一级一级的建立。

解决方案 »

  1.   

    不用一级一级的建,可以多级多级的建:)
    private File createFile(String fileName)  {  File file = new File(fileName );
      if( ! file.exists() ) {
          File parent = file.getAbsoluteFile().getParent();
          if( parent.exists() || parent.mkdirs()) 
              if( file.createNewFile() )
                 return file;
          return null;    
      }
      return file;
    }