document UTF-16 BOM writing (closes #37)
Project: http://git-wip-us.apache.org/repos/asf/incubator-groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-groovy/commit/50e9bad5 Tree: http://git-wip-us.apache.org/repos/asf/incubator-groovy/tree/50e9bad5 Diff: http://git-wip-us.apache.org/repos/asf/incubator-groovy/diff/50e9bad5 Branch: refs/heads/GROOVY_2_4_X Commit: 50e9bad55f96ca181391bfff8caaad4b33216817 Parents: 68136a8 Author: Keegan Witt <keeganw...@gmail.com> Authored: Tue Jun 9 12:40:20 2015 -0400 Committer: pascalschumacher <pascalschumac...@gmx.net> Committed: Tue Jun 9 19:19:18 2015 +0200 ---------------------------------------------------------------------- .../groovy/runtime/ResourceGroovyMethods.java | 38 ++++++++++++++------ 1 file changed, 27 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-groovy/blob/50e9bad5/src/main/org/codehaus/groovy/runtime/ResourceGroovyMethods.java ---------------------------------------------------------------------- diff --git a/src/main/org/codehaus/groovy/runtime/ResourceGroovyMethods.java b/src/main/org/codehaus/groovy/runtime/ResourceGroovyMethods.java index 5b2bcac..7740075 100644 --- a/src/main/org/codehaus/groovy/runtime/ResourceGroovyMethods.java +++ b/src/main/org/codehaus/groovy/runtime/ResourceGroovyMethods.java @@ -827,7 +827,9 @@ public class ResourceGroovyMethods extends DefaultGroovyMethodsSupport { } /** - * Write the text to the File, using the specified encoding. + * Write the text to the File, using the specified encoding. If the given + * charset is "UTF-16BE" or "UTF-16LE" (or an equivalent alias), the + * requisite byte order mark is written to the file before the text. * * @param file a File * @param text the text to write to the File @@ -956,7 +958,10 @@ public class ResourceGroovyMethods extends DefaultGroovyMethodsSupport { } /** - * Append the text at the end of the File, using a specified encoding. + * 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) + * 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 @@ -1742,8 +1747,9 @@ public class ResourceGroovyMethods extends DefaultGroovyMethodsSupport { /** * Helper method to create a buffered writer for a file. If the given - * charset is "UTF-16BE" or "UTF-16LE", the requisite byte order mark is - * written to the stream before the writer is returned. + * charset is "UTF-16BE" or "UTF-16LE" (or an equivalent alias), the + * requisite byte order mark is written to the stream before the writer + * is returned. * * @param file a File * @param charset the name of the encoding used to write in this file @@ -1773,7 +1779,9 @@ public class ResourceGroovyMethods extends DefaultGroovyMethodsSupport { /** * Creates a buffered writer for this file, writing data using the given - * encoding. + * encoding. If the given charset is "UTF-16BE" or "UTF-16LE" (or an + * equivalent alias), the requisite byte order mark is written to the + * stream before the writer is returned. * * @param file a File * @param charset the name of the encoding used to write in this file @@ -1820,7 +1828,9 @@ public class ResourceGroovyMethods extends DefaultGroovyMethodsSupport { /** * Creates a new BufferedWriter for this file, passes it to the closure, and * ensures the stream is flushed and closed after the closure returns. - * The writer will use the given charset encoding. + * The writer will use the given charset encoding. If the given charset is + * "UTF-16BE" or "UTF-16LE" (or an equivalent alias), the requisite byte + * order mark is written to the stream when the writer is created. * * @param file a File * @param charset the charset used @@ -1834,8 +1844,10 @@ public class ResourceGroovyMethods extends DefaultGroovyMethodsSupport { } /** - * Create a new BufferedWriter which will append to this - * file. The writer is passed to the closure and will be closed before + * Create a new BufferedWriter which will append to this file. If the + * given charset is "UTF-16BE" or "UTF-16LE" (or an equivalent alias), the + * requisite byte order mark is written to the stream when the writer is + * created. The writer is passed to the closure and will be closed before * this method returns. * * @param file a File @@ -1877,7 +1889,9 @@ public class ResourceGroovyMethods extends DefaultGroovyMethodsSupport { /** * Create a new PrintWriter for this file, using specified - * charset. + * charset. If the given charset is "UTF-16BE" or "UTF-16LE" (or an + * equivalent alias), the requisite byte order mark is written to the + * stream before the writer is returned. * * @param file a File * @param charset the charset @@ -1905,8 +1919,10 @@ public class ResourceGroovyMethods extends DefaultGroovyMethodsSupport { } /** - * Create a new PrintWriter with a specified charset for - * this file. The writer is passed to the closure, and will be closed + * Create a new PrintWriter with a specified charset for this file. If the + * given charset is "UTF-16BE" or "UTF-16LE" (or an equivalent alias), the + * requisite byte order mark is written to the stream when the writer is + * created. The writer is passed to the closure, and will be closed * before this method returns. * * @param file a File