Skip to content

Commit 0c05270

Browse files
committed
Using Files.writeString on JRE 11 to append files
1 parent 7983d57 commit 0c05270

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/main/java11/org/codehaus/plexus/util/BaseFileUtils.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.nio.charset.Charset;
55
import java.nio.file.Files;
66
import java.nio.file.Path;
7+
import java.nio.file.StandardOpenOption;
78

89
/**
910
* Implementation specific to Java SE 11 version.
@@ -26,4 +27,17 @@ static void fileWrite( Path path, String encoding, String data ) throws IOExcept
2627
Files.writeString( path, data );
2728
}
2829
}
30+
31+
static void fileAppend( Path path, String encoding, String data ) throws IOException
32+
{
33+
if ( encoding != null )
34+
{
35+
Files.writeString( path, data, Charset.forName( encoding ),
36+
StandardOpenOption.APPEND, StandardOpenOption.CREATE );
37+
}
38+
else
39+
{
40+
Files.writeString( path, data,StandardOpenOption.APPEND, StandardOpenOption.CREATE );
41+
}
42+
}
2943
}

0 commit comments

Comments
 (0)