You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2023/01/14 09:06:10 UTC
[groovy] branch GROOVY_4_0_X updated: Replace `Path#toFile.exists()` with `Files#exists`
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch GROOVY_4_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/GROOVY_4_0_X by this push:
new 3ce7307826 Replace `Path#toFile.exists()` with `Files#exists`
3ce7307826 is described below
commit 3ce73078269cfc048d1a0e9e5c65ab8d5e1a0566
Author: Matyrobbrt <ma...@gmail.com>
AuthorDate: Fri Jan 13 16:14:40 2023 +0200
Replace `Path#toFile.exists()` with `Files#exists`
(cherry picked from commit 1334242e2ecc1fe4b9b4a3821a1324805c0112ed)
---
.../main/java/org/apache/groovy/nio/extensions/NioExtensions.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/subprojects/groovy-nio/src/main/java/org/apache/groovy/nio/extensions/NioExtensions.java b/subprojects/groovy-nio/src/main/java/org/apache/groovy/nio/extensions/NioExtensions.java
index 499c579294..1f3a68be51 100644
--- a/subprojects/groovy-nio/src/main/java/org/apache/groovy/nio/extensions/NioExtensions.java
+++ b/subprojects/groovy-nio/src/main/java/org/apache/groovy/nio/extensions/NioExtensions.java
@@ -701,7 +701,7 @@ public class NioExtensions extends DefaultGroovyMethodsSupport {
Writer writer = null;
try {
Charset resolvedCharset = Charset.forName(charset);
- boolean shouldWriteBom = writeBom && !self.toFile().exists();
+ boolean shouldWriteBom = writeBom && !Files.exists(self);
OutputStream out = Files.newOutputStream(self, CREATE, APPEND);
if (shouldWriteBom) {
writeUTF16BomIfRequired(out, resolvedCharset);
@@ -819,7 +819,7 @@ public class NioExtensions extends DefaultGroovyMethodsSupport {
private static void appendBuffered(Path file, Object text, String charset, boolean writeBom) throws IOException {
BufferedWriter writer = null;
try {
- boolean shouldWriteBom = writeBom && !file.toFile().exists();
+ boolean shouldWriteBom = writeBom && !Files.exists(file);
writer = newWriter(file, charset, true);
if (shouldWriteBom) {
writeUTF16BomIfRequired(writer, charset);
@@ -1627,7 +1627,7 @@ public class NioExtensions extends DefaultGroovyMethodsSupport {
* @since 2.5.0
*/
public static BufferedWriter newWriter(Path self, String charset, boolean append, boolean writeBom) throws IOException {
- boolean shouldWriteBom = writeBom && !self.toFile().exists();
+ boolean shouldWriteBom = writeBom && !Files.exists(self);
if (append) {
BufferedWriter writer = Files.newBufferedWriter(self, Charset.forName(charset), CREATE, APPEND);
if (shouldWriteBom) {