diff options
Diffstat (limited to 'src/main/java/cuchaz/enigma/convert/MatchesWriter.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/convert/MatchesWriter.java | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/main/java/cuchaz/enigma/convert/MatchesWriter.java b/src/main/java/cuchaz/enigma/convert/MatchesWriter.java index baf7929..dccbf6f 100644 --- a/src/main/java/cuchaz/enigma/convert/MatchesWriter.java +++ b/src/main/java/cuchaz/enigma/convert/MatchesWriter.java | |||
| @@ -10,9 +10,8 @@ | |||
| 10 | ******************************************************************************/ | 10 | ******************************************************************************/ |
| 11 | package cuchaz.enigma.convert; | 11 | package cuchaz.enigma.convert; |
| 12 | 12 | ||
| 13 | import java.io.File; | 13 | import java.io.*; |
| 14 | import java.io.FileWriter; | 14 | import java.nio.charset.Charset; |
| 15 | import java.io.IOException; | ||
| 16 | import java.util.Map; | 15 | import java.util.Map; |
| 17 | 16 | ||
| 18 | import cuchaz.enigma.mapping.BehaviorEntry; | 17 | import cuchaz.enigma.mapping.BehaviorEntry; |
| @@ -25,14 +24,14 @@ public class MatchesWriter { | |||
| 25 | 24 | ||
| 26 | public static void writeClasses(ClassMatches matches, File file) | 25 | public static void writeClasses(ClassMatches matches, File file) |
| 27 | throws IOException { | 26 | throws IOException { |
| 28 | try (FileWriter out = new FileWriter(file)) { | 27 | try (OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(file), Charset.forName("UTF-8"))) { |
| 29 | for (ClassMatch match : matches) { | 28 | for (ClassMatch match : matches) { |
| 30 | writeClassMatch(out, match); | 29 | writeClassMatch(out, match); |
| 31 | } | 30 | } |
| 32 | } | 31 | } |
| 33 | } | 32 | } |
| 34 | 33 | ||
| 35 | private static void writeClassMatch(FileWriter out, ClassMatch match) | 34 | private static void writeClassMatch(OutputStreamWriter out, ClassMatch match) |
| 36 | throws IOException { | 35 | throws IOException { |
| 37 | writeClasses(out, match.sourceClasses); | 36 | writeClasses(out, match.sourceClasses); |
| 38 | out.write(":"); | 37 | out.write(":"); |
| @@ -40,7 +39,7 @@ public class MatchesWriter { | |||
| 40 | out.write("\n"); | 39 | out.write("\n"); |
| 41 | } | 40 | } |
| 42 | 41 | ||
| 43 | private static void writeClasses(FileWriter out, Iterable<ClassEntry> classes) | 42 | private static void writeClasses(OutputStreamWriter out, Iterable<ClassEntry> classes) |
| 44 | throws IOException { | 43 | throws IOException { |
| 45 | boolean isFirst = true; | 44 | boolean isFirst = true; |
| 46 | for (ClassEntry entry : classes) { | 45 | for (ClassEntry entry : classes) { |
| @@ -55,7 +54,7 @@ public class MatchesWriter { | |||
| 55 | 54 | ||
| 56 | public static <T extends Entry> void writeMembers(MemberMatches<T> matches, File file) | 55 | public static <T extends Entry> void writeMembers(MemberMatches<T> matches, File file) |
| 57 | throws IOException { | 56 | throws IOException { |
| 58 | try (FileWriter out = new FileWriter(file)) { | 57 | try (OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(file), Charset.forName("UTF-8"))) { |
| 59 | for (Map.Entry<T, T> match : matches.matches().entrySet()) { | 58 | for (Map.Entry<T, T> match : matches.matches().entrySet()) { |
| 60 | writeMemberMatch(out, match.getKey(), match.getValue()); | 59 | writeMemberMatch(out, match.getKey(), match.getValue()); |
| 61 | } | 60 | } |
| @@ -71,7 +70,7 @@ public class MatchesWriter { | |||
| 71 | } | 70 | } |
| 72 | } | 71 | } |
| 73 | 72 | ||
| 74 | private static <T extends Entry> void writeMemberMatch(FileWriter out, T source, T dest) | 73 | private static <T extends Entry> void writeMemberMatch(OutputStreamWriter out, T source, T dest) |
| 75 | throws IOException { | 74 | throws IOException { |
| 76 | if (source != null) { | 75 | if (source != null) { |
| 77 | writeEntry(out, source); | 76 | writeEntry(out, source); |
| @@ -83,14 +82,14 @@ public class MatchesWriter { | |||
| 83 | out.write("\n"); | 82 | out.write("\n"); |
| 84 | } | 83 | } |
| 85 | 84 | ||
| 86 | private static <T extends Entry> void writeUnmatchableEntry(FileWriter out, T entry) | 85 | private static <T extends Entry> void writeUnmatchableEntry(OutputStreamWriter out, T entry) |
| 87 | throws IOException { | 86 | throws IOException { |
| 88 | out.write("!"); | 87 | out.write("!"); |
| 89 | writeEntry(out, entry); | 88 | writeEntry(out, entry); |
| 90 | out.write("\n"); | 89 | out.write("\n"); |
| 91 | } | 90 | } |
| 92 | 91 | ||
| 93 | private static <T extends Entry> void writeEntry(FileWriter out, T entry) | 92 | private static <T extends Entry> void writeEntry(OutputStreamWriter out, T entry) |
| 94 | throws IOException { | 93 | throws IOException { |
| 95 | if (entry instanceof FieldEntry) { | 94 | if (entry instanceof FieldEntry) { |
| 96 | writeField(out, (FieldEntry) entry); | 95 | writeField(out, (FieldEntry) entry); |
| @@ -99,7 +98,7 @@ public class MatchesWriter { | |||
| 99 | } | 98 | } |
| 100 | } | 99 | } |
| 101 | 100 | ||
| 102 | private static void writeField(FileWriter out, FieldEntry fieldEntry) | 101 | private static void writeField(OutputStreamWriter out, FieldEntry fieldEntry) |
| 103 | throws IOException { | 102 | throws IOException { |
| 104 | out.write(fieldEntry.getClassName()); | 103 | out.write(fieldEntry.getClassName()); |
| 105 | out.write(" "); | 104 | out.write(" "); |
| @@ -108,7 +107,7 @@ public class MatchesWriter { | |||
| 108 | out.write(fieldEntry.getType().toString()); | 107 | out.write(fieldEntry.getType().toString()); |
| 109 | } | 108 | } |
| 110 | 109 | ||
| 111 | private static void writeBehavior(FileWriter out, BehaviorEntry behaviorEntry) | 110 | private static void writeBehavior(OutputStreamWriter out, BehaviorEntry behaviorEntry) |
| 112 | throws IOException { | 111 | throws IOException { |
| 113 | out.write(behaviorEntry.getClassName()); | 112 | out.write(behaviorEntry.getClassName()); |
| 114 | out.write(" "); | 113 | out.write(" "); |