private static void output(ConstraintParser parser, String outputFile) throws IOException { String output = parser.parse(); if (StringUtils.isEmpty(outputFile)) { System.out.println(output); } else { File file = new File(outputFile); file.getParentFile().mkdirs(); try (Writer writer = new OutputStreamWriter(new FileOutputStream(file), "utf-8")) { writer.write(output); } } }