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

Path.write() appends when encoding parameter present

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.4.5
    • Component/s: None
    • Labels:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: