Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2f68e93

Browse files
committedApr 23, 2022
Fix regression and deprecate: FileUtils.fileAppend should create file if not exist.
1 parent d3823dc commit 2f68e93

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed
 

‎src/main/java/org/codehaus/plexus/util/FileUtils.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,8 @@ private static InputStreamReader getInputStreamReader( File file, String encodin
389389
* @param fileName The path of the file to write.
390390
* @param data The content to write to the file.
391391
* @throws IOException if any
392+
* @deprecated use {@code java.nio.files.Files.write(filename, data.getBytes(encoding),
393+
* StandardOpenOption.APPEND, StandardOpenOption.CREATE)}
392394
*/
393395
public static void fileAppend( String fileName, String data )
394396
throws IOException
@@ -403,11 +405,14 @@ public static void fileAppend( String fileName, String data )
403405
* @param encoding The encoding of the file.
404406
* @param data The content to write to the file.
405407
* @throws IOException if any
408+
* @deprecated use {@code java.nio.files.Files.write(filename, data.getBytes(encoding),
409+
* StandardOpenOption.APPEND, StandardOpenOption.CREATE)}
406410
*/
407411
public static void fileAppend( String fileName, String encoding, String data )
408412
throws IOException
409413
{
410-
try ( OutputStream out = Files.newOutputStream( Paths.get(fileName), StandardOpenOption.APPEND ) )
414+
try ( OutputStream out = Files.newOutputStream( Paths.get(fileName),
415+
StandardOpenOption.APPEND, StandardOpenOption.CREATE ) )
411416
{
412417
if ( encoding != null )
413418
{

0 commit comments

Comments
 (0)
Please sign in to comment.