|
27 | 27 | import okhttp3.Response; |
28 | 28 | import okhttp3.ResponseBody; |
29 | 29 |
|
30 | | -import java.io.ByteArrayInputStream; |
31 | | -import java.io.IOException; |
32 | | -import java.io.InputStream; |
33 | | -import java.nio.charset.StandardCharsets; |
| 30 | +import java.io.*; |
34 | 31 | import java.nio.file.Files; |
35 | 32 | import java.nio.file.Path; |
36 | | -import java.nio.file.StandardCopyOption; |
37 | 33 | import java.util.List; |
38 | 34 | import java.util.concurrent.CompletableFuture; |
39 | 35 |
|
@@ -84,7 +80,7 @@ public CompletableFuture<VersionsFile> updateFile(String url){ |
84 | 80 | // User is using old versions.json URL |
85 | 81 | if(newVersions.getFileVersion() == -1){ |
86 | 82 | logger.warn("Remote JSON file does not have a 'file_version' property set!"); |
87 | | - logger.warn("Make sure the URL points to an updated version."); |
| 83 | + logger.warn("Make sure the URL points to an updated versions file."); |
88 | 84 | logger.warnFormat("New URL: %s", OneVersionRemake.DEF_VERSIONS_URL); |
89 | 85 |
|
90 | 86 | return null; |
@@ -119,10 +115,13 @@ private VersionsFile copyAndUpdate(String json){ |
119 | 115 | if(json == null) |
120 | 116 | return null; |
121 | 117 |
|
122 | | - InputStream stream = new ByteArrayInputStream(json.getBytes(StandardCharsets.UTF_8)); |
123 | | - |
124 | 118 | try{ |
125 | | - Files.copy(stream, file, StandardCopyOption.REPLACE_EXISTING); |
| 119 | + FileWriter fileWriter = new FileWriter(file.toFile(), false); |
| 120 | + BufferedWriter writer = new BufferedWriter(fileWriter); |
| 121 | + |
| 122 | + writer.write(json); |
| 123 | + writer.close(); |
| 124 | + |
126 | 125 | return (versions = getVersionsFile(json)); |
127 | 126 | }catch(IOException ex){ |
128 | 127 | logger.warn("Encountered IOException while saving the versions.json file.", ex); |
|
0 commit comments