Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-7553

Path.write() appends when encoding parameter present

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.4.5
    • None
    • None

    Description

      Path.write() is expected to overwrite and not append, which it does, except in when the encoding parameter is passed, as demonstrated here

      def p = java.nio.file.Paths.get("foo.txt")
      p.write("1")
      p.write("2")
      assert p.text == "2"  // passes
      java.nio.file.Files.delete(p)
      p.write("1", "UTF-8")
      p.write("2", "UTF-8")
      assert p.text == "2"  // fails, is '12'
      java.nio.file.Files.delete(p)
      

      Attachments

        Activity

          People

            keegan Keegan Witt
            keegan Keegan Witt
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: