Skip to content

Commit

Permalink
Fix regression and deprecate: FileUtils.fileAppend should create file…
Browse files Browse the repository at this point in the history
… if not exist.
  • Loading branch information
slachiewicz committed Apr 23, 2022
1 parent d3823dc commit 2f68e93
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/java/org/codehaus/plexus/util/FileUtils.java
Expand Up @@ -389,6 +389,8 @@ private static InputStreamReader getInputStreamReader( File file, String encodin
* @param fileName The path of the file to write.
* @param data The content to write to the file.
* @throws IOException if any
* @deprecated use {@code java.nio.files.Files.write(filename, data.getBytes(encoding),
* StandardOpenOption.APPEND, StandardOpenOption.CREATE)}
*/

This comment has been minimized.

Copy link
@gnodet

gnodet Apr 27, 2022

Member

Should we also add a @deprecated annotation ?

public static void fileAppend( String fileName, String data )
throws IOException
Expand All @@ -403,11 +405,14 @@ public static void fileAppend( String fileName, String data )
* @param encoding The encoding of the file.
* @param data The content to write to the file.
* @throws IOException if any
* @deprecated use {@code java.nio.files.Files.write(filename, data.getBytes(encoding),
* StandardOpenOption.APPEND, StandardOpenOption.CREATE)}
*/

This comment has been minimized.

Copy link
@gnodet

gnodet Apr 27, 2022

Member

Same here ?

public static void fileAppend( String fileName, String encoding, String data )
throws IOException
{
try ( OutputStream out = Files.newOutputStream( Paths.get(fileName), StandardOpenOption.APPEND ) )
try ( OutputStream out = Files.newOutputStream( Paths.get(fileName),
StandardOpenOption.APPEND, StandardOpenOption.CREATE ) )
{
if ( encoding != null )
{
Expand Down

0 comments on commit 2f68e93

Please sign in to comment.