|
25 | 25 |
|
26 | 26 | import java.io.File; |
27 | 27 | import java.io.IOException; |
| 28 | +import java.nio.charset.StandardCharsets; |
28 | 29 | import java.nio.file.Files; |
29 | 30 | import java.nio.file.Path; |
30 | 31 | import java.nio.file.Paths; |
@@ -63,20 +64,20 @@ static void writeFile(File folder, String file, String content) { |
63 | 64 |
|
64 | 65 | /** |
65 | 66 | * Read the content of a {@link File} and convert it to a String in base 64. |
66 | | - * We expect the content of the file to be encoded using {@link com.cloud.utils.StringUtils#getPreferredCharset()} |
| 67 | + * We expect the content of the file to be encoded using {@link StandardCharsets#US_ASC} |
67 | 68 | */ |
68 | 69 | public static String fileToBase64String(File isoFile) throws IOException { |
69 | 70 | byte[] encoded = Base64.encodeBase64(FileUtils.readFileToByteArray(isoFile)); |
70 | | - return new String(encoded, com.cloud.utils.StringUtils.getPreferredCharset()); |
| 71 | + return new String(encoded, StandardCharsets.US_ASCII); |
71 | 72 | } |
72 | 73 |
|
73 | 74 | /** |
74 | 75 | * Writes a String encoded in base 64 to a file in the given folder. |
75 | 76 | * The content will be decoded and then written to the file. Be aware that we will overwrite the content of the file if it already exists. |
76 | | - * Moreover, the content will must be encoded in {@link com.cloud.utils.StringUtils#getPreferredCharset()} before it is encoded in base 64. |
| 77 | + * Moreover, the content will must be encoded in {@link StandardCharsets#US_ASCII} before it is encoded in base 64. |
77 | 78 | */ |
78 | 79 | public static File base64StringToFile(String encodedIsoData, String folder, String fileName) throws IOException { |
79 | | - byte[] decoded = Base64.decodeBase64(encodedIsoData.getBytes(com.cloud.utils.StringUtils.getPreferredCharset())); |
| 80 | + byte[] decoded = Base64.decodeBase64(encodedIsoData.getBytes(StandardCharsets.US_ASCII)); |
80 | 81 | Path destPath = Paths.get(folder, fileName); |
81 | 82 | return Files.write(destPath, decoded).toFile(); |
82 | 83 | } |
|
0 commit comments