Skip to content

Commit

Permalink
Consolidated code
Browse files Browse the repository at this point in the history
  • Loading branch information
mkarg committed Jan 21, 2023
1 parent 62964ec commit 9f17d62
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
5 changes: 0 additions & 5 deletions src/main/java/org/codehaus/plexus/util/BaseFileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,4 @@ static void fileWrite( Path path, String encoding, String data, OpenOption... op
byte[] bytes = encoding != null ? data.getBytes( encoding ) : data.getBytes();
Files.write( path, bytes, openOptions );
}

static void fileAppend( Path path, String encoding, String data ) throws IOException
{
fileWrite( path, encoding, data, StandardOpenOption.APPEND, StandardOpenOption.CREATE );
}
}
6 changes: 6 additions & 0 deletions src/main/java/org/codehaus/plexus/util/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.security.SecureRandom;
import java.text.DecimalFormat;
import java.util.ArrayList;
Expand Down Expand Up @@ -389,6 +390,11 @@ public static void fileAppend( String fileName, String encoding, String data )
fileAppend( Paths.get( fileName), encoding, data );
}

private static void fileAppend( Path path, String encoding, String data ) throws IOException
{
fileWrite( path, encoding, data, StandardOpenOption.APPEND, StandardOpenOption.CREATE );
}

/**
* Writes data to a file. The file will be created if it does not exist. Note: the data is written with platform
* encoding
Expand Down
5 changes: 0 additions & 5 deletions src/main/java11/org/codehaus/plexus/util/BaseFileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,4 @@ static void fileWrite( Path path, String encoding, String data, OpenOption... op
Files.writeString( path, data, openOptions );
}
}

static void fileAppend( Path path, String encoding, String data ) throws IOException
{
fileWrite( path, encoding, data, StandardOpenOption.APPEND, StandardOpenOption.CREATE );
}
}

0 comments on commit 9f17d62

Please sign in to comment.