Skip to content

Commit

Permalink
Always use UTF-8 for config files
Browse files Browse the repository at this point in the history
  • Loading branch information
Brokkonaut committed Nov 12, 2018
1 parent 339af37 commit a9bd710
Showing 1 changed file with 5 additions and 3 deletions.
Expand Up @@ -3,8 +3,9 @@
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Scanner;
Expand All @@ -14,6 +15,7 @@
import org.bukkit.configuration.file.YamlConfiguration;

import com.Acrobot.Breeze.Configuration.Annotations.PrecededBySpace;
import com.google.common.base.Charsets;

/**
* A class which can be used to make configs easier to load
Expand All @@ -33,7 +35,7 @@ public static void pairFileAndClass(File file, Class<?> clazz) {
FileConfiguration config = YamlConfiguration.loadConfiguration(file);

try {
BufferedWriter writer = new BufferedWriter(new FileWriter(file, true));
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file, true), Charsets.UTF_8));

if (!endsWithSpace(file)) {
writer.newLine();
Expand Down Expand Up @@ -80,7 +82,7 @@ public static void pairFileAndClass(File file, Class<?> clazz) {
*/
public static boolean endsWithSpace(File file) {
try {
Scanner scanner = new Scanner(file);
Scanner scanner = new Scanner(file, "UTF-8");
String lastLine = "";

while (scanner.hasNextLine()) {
Expand Down

0 comments on commit a9bd710

Please sign in to comment.