diff --git a/avrohugger-core/src/main/scala/format/abstractions/SourceFormat.scala b/avrohugger-core/src/main/scala/format/abstractions/SourceFormat.scala index 06a50f35..7284daae 100644 --- a/avrohugger-core/src/main/scala/format/abstractions/SourceFormat.scala +++ b/avrohugger-core/src/main/scala/format/abstractions/SourceFormat.scala @@ -222,7 +222,8 @@ trait SourceFormat { } val contents = compilationUnit.codeString.getBytes() try { // delete old and/or create new - Files.deleteIfExists(path) + Files.deleteIfExists(path) // delete file if exists + Files.createDirectories(path.getParent) // create all parent folders Files.write(path, contents, StandardOpenOption.CREATE) () } @@ -232,4 +233,4 @@ trait SourceFormat { } } -} \ No newline at end of file +}