Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
package com.ulisesbocchio.jasyptmavenplugin.mojo;

import org.apache.maven.plugin.MojoExecutionException;

import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Properties;

import org.apache.maven.plugin.MojoExecutionException;

/**
* A service for operating on files.
*
* @author Rupert Madden-Abbott
* @version $Id: $Id
*/
public class FileService {

private static final Charset CHARSET;
static {
String charset = System.getProperty("file.encoding", "UTF-8");
CHARSET = Charset.forName(charset);
}
/**
* Read a file.
*
Expand All @@ -23,7 +30,7 @@ public class FileService {
*/
public static String read(final Path path) throws MojoExecutionException {
try {
return new String(Files.readAllBytes(path));
return new String(Files.readAllBytes(path), CHARSET);
} catch (IOException e) {
throw new MojoExecutionException("Unable to read file " + path, e);
}
Expand All @@ -38,7 +45,7 @@ public static String read(final Path path) throws MojoExecutionException {
*/
public static void write(final Path path, final String contents) throws MojoExecutionException {
try {
Files.write(path, contents.getBytes());
Files.write(path, contents.getBytes(CHARSET));
} catch (IOException e) {
throw new MojoExecutionException("Unable to write file " + path, e);
}
Expand Down