Github user keeganwitt commented on a diff in the pull request:

    https://github.com/apache/incubator-groovy/pull/176#discussion_r44361018
  
    --- Diff: src/main/org/codehaus/groovy/runtime/ResourceGroovyMethods.java 
---
    @@ -974,11 +1021,30 @@ public static void append(File self, InputStream 
stream) throws IOException {
          * @since 1.0
          */
         public static void append(File file, Object text, String charset) 
throws IOException {
    +        append(file, text, charset, false);
    +    }
    +
    +    /**
    +     * Append the text at the end of the File, using a specified encoding. 
 If
    +     * the given charset is "UTF-16BE" or "UTF-16LE" (or an equivalent 
alias),
    +     * <code>writeBom</code> is <code>true</code>, and the file doesn't 
already
    +     * exist, the requisite byte order mark is written to the file before 
the
    +     * text is appended.
    +     *
    +     * @param file     a File
    +     * @param text     the text to append at the end of the File
    +     * @param charset  the charset used
    +     * @param writeBom whether to write a BOM
    +     * @throws IOException if an IOException occurs.
    +     * @since 2.5.0
    +     */
    +    public static void append(File file, Object text, String charset, 
boolean writeBom) throws IOException {
             Writer writer = null;
             try {
    +            boolean shouldWriteBom = writeBom && !file.exists();
                 FileOutputStream out = new FileOutputStream(file, true);
    -            if (!file.exists()) {
    -                writeUTF16BomIfRequired(charset, out);
    +            if (shouldWriteBom) {
    --- End diff --
    
    The check is still there, I just pulled it out into a separate variable 
(`shouldWriteBom`).  I could do it without a variable, I only use it once so 
it's not really necessary.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to