diff --git a/src/main/java/org/eclipse/basyx/submodel/restapi/vab/VABSubmodelAPI.java b/src/main/java/org/eclipse/basyx/submodel/restapi/vab/VABSubmodelAPI.java index 9b6e6c9f..3ce9a036 100644 --- a/src/main/java/org/eclipse/basyx/submodel/restapi/vab/VABSubmodelAPI.java +++ b/src/main/java/org/eclipse/basyx/submodel/restapi/vab/VABSubmodelAPI.java @@ -164,13 +164,10 @@ private void createFile(String idShortPath, Object newValue, ISubmodelElement su java.io.File targetFile = new java.io.File(filePath); - FileOutputStream outStream = new FileOutputStream(targetFile); - InputStream inStream = (InputStream) newValue; - - IOUtils.copy(inStream, outStream); - - inStream.close(); - outStream.close(); + try (FileOutputStream outStream = new FileOutputStream(targetFile); + InputStream inStream = (InputStream) newValue) { + IOUtils.copy(inStream, outStream); + } } private String getFilePath(String idShortPath, File file) {