Forum Discussion

zellahee's avatar
New Contributor
5 years ago

create a folder and insert xml file in the folder at runtime


Using a groovy script, i want to create a new folder and insert xml files in the folder at runtime.


Can anyone help me?

2 Replies

  • JHunt's avatar
    Community Hero
    // String contents = ...
    new File("myfolder").mkdirs()
    new File("myfolder/mydoc.xml").text = contents
    • zellahee's avatar
      New Contributor

      My codes and it works:


      def path = new context) // Getting relative path
      def bkpath = (path.projectPath + "\\yourFolder\\")
      def folderName = ("XXXX" + variable)
      def RMDir = new File("$bkpath/$folderName") // Path of folder to create



      //Writing external file
      def xxxx = context.expand('${Export_xxxxx#Response}')
      new File("${RMDir}/" + "xxxx.xml").write( xxxx )