diff options
author | ralph isenmann | 2020-12-01 14:21:17 +0100 |
---|---|---|
committer | ralph isenmann | 2020-12-01 14:21:51 +0100 |
commit | 6b4aa287102a5de98ad03fd8965515c416d93044 (patch) | |
tree | 78569e69f432aff997cbea54505ba698138bab7a /dozentenmodul/src/main | |
parent | [client] Refactoring (diff) | |
download | tutor-module-6b4aa287102a5de98ad03fd8965515c416d93044.tar.gz tutor-module-6b4aa287102a5de98ad03fd8965515c416d93044.tar.xz tutor-module-6b4aa287102a5de98ad03fd8965515c416d93044.zip |
[client] fix eol separator
A given dockerfile with windows eol style ("\r\n") will now be converted to unix eol ("\n")
Diffstat (limited to 'dozentenmodul/src/main')
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/model/ContainerDefinition.java | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/model/ContainerDefinition.java b/dozentenmodul/src/main/java/org/openslx/dozmod/model/ContainerDefinition.java index 46dba2e0..92ec6607 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/model/ContainerDefinition.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/model/ContainerDefinition.java @@ -145,16 +145,22 @@ public class ContainerDefinition { } private String readContainerRecipe(File file) { - byte[] rawFile = null; + String recipe = null; try { + BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file)); - rawFile = new byte[(int) file.length()]; + byte[] rawFile = new byte[(int) file.length()]; bis.read(rawFile); + String rawRecipe = new String(rawFile, StandardCharsets.UTF_8); + + // replace windows by unix EOL + recipe = rawRecipe.replaceAll("\\r\\n", "\n"); + } catch (IOException e) { LOGGER.error("Could not read Container Recipe", e); } - return new String(rawFile, StandardCharsets.UTF_8); + return recipe; } /** |