Example usage for java.nio.file Files copy

List of usage examples for java.nio.file Files copy

Introduction

In this page you can find the example usage for java.nio.file Files copy.

Prototype

public static long copy(InputStream in, Path target, CopyOption... options) throws IOException 

Source Link

Document

Copies all bytes from an input stream to a file.

Usage

From source file:de.ncoder.studipsync.studip.jsoup.JsoupStudipAdapter.java

public void displayWebsite() {
    try {//from  w  w  w .  java 2  s.com
        Path tmp = Files.createTempFile("studip-dump", ".html");
        Files.copy(new ByteArrayInputStream(document.outerHtml().getBytes()), tmp,
                StandardCopyOption.REPLACE_EXISTING);
        log.info("Displaying " + con.url());
        ui.displayWebpage(tmp.toUri());
    } catch (IOException e) {
        log.warn("Can't write page dump", e);
    }
}

From source file:com.skynetcomputing.skynetclient.persistence.PersistenceManager.java

/**
 * Saves given data file to file system, and returns the SrzData object.
 *
 * @param dataFile//from ww w .  j av  a 2 s. c om
 * @return
 * @throws IOException
 */
public SrzData saveDataFile(File dataFile) throws IOException {
    File dataDir = new File(rootDir + TASK_DIR + DATA_DIR);
    dataDir.mkdirs();
    SrzData output = readDataFile(dataFile);
    File outputFile = new File(
            String.format("%s%s%s%d%s", rootDir, TASK_DIR, DATA_DIR, output.getID(), SrzData.EXT));
    Files.copy(dataFile.toPath(), outputFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
    return output;
}

From source file:nz.co.fortytwo.signalk.processor.UploadProcessor.java

private void processUpload(Exchange exchange) throws Exception {
    logger.debug("Begin import:" + exchange.getIn().getHeaders());
    if (exchange.getIn().getBody() != null) {
        logger.debug("Body class:" + exchange.getIn().getBody().getClass());
    } else {/*from w w w .ja  va2 s.  co  m*/
        logger.debug("Body class is null");
    }
    //logger.debug("Begin import:"+ exchange.getIn().getBody());
    MediaType mediaType = exchange.getIn().getHeader(Exchange.CONTENT_TYPE, MediaType.class);
    InputRepresentation representation = new InputRepresentation((InputStream) exchange.getIn().getBody(),
            mediaType);
    logger.debug("Found MIME:" + mediaType + ", length:"
            + exchange.getIn().getHeader(Exchange.CONTENT_LENGTH, Integer.class));
    //make a reply
    Json reply = Json.read("{\"files\": []}");
    Json files = reply.at("files");

    try {
        List<FileItem> items = new RestletFileUpload(new DiskFileItemFactory())
                .parseRepresentation(representation);
        logger.debug("Begin import files:" + items);
        for (FileItem item : items) {
            if (!item.isFormField()) {
                InputStream inputStream = item.getInputStream();

                Path destination = Paths.get(
                        Util.getConfigProperty(STATIC_DIR) + Util.getConfigProperty(MAP_DIR) + item.getName());
                logger.debug("Save import file:" + destination);
                long len = Files.copy(inputStream, destination, StandardCopyOption.REPLACE_EXISTING);
                Json f = Json.object();
                f.set("name", item.getName());
                f.set("size", len);
                files.add(f);
                install(destination);
            }
        }
    } catch (FileUploadException | IOException e) {
        logger.error(e.getMessage(), e);
    }
    exchange.getIn().setBody(reply);
}

From source file:com.tocsi.images.ImageListBean.java

public void handleFileUpload(FileUploadEvent event) {
    if (event.getFile() != null) {
        try {/*from   w w  w. ja va  2s . c o  m*/
            UploadedFile uf = (UploadedFile) event.getFile();
            File folder = new File(GlobalsBean.destOriginal);
            //File folderThumb = new File(destThumbnail);
            String filename = FilenameUtils.getBaseName(uf.getFileName());
            String extension = FilenameUtils.getExtension(uf.getFileName());
            File file = File.createTempFile(filename + "-", "." + extension, folder);
            //File fileThumb = File.createTempFile(filename + "-", "." + extension, folderThumb);

            //resize image here
            BufferedImage originalImage = ImageIO.read(uf.getInputstream());
            InputStream is = uf.getInputstream();
            if (originalImage.getWidth() > 700) { //resize image if image's width excess 700px
                BufferedImage origImage = Scalr.resize(originalImage, Scalr.Method.QUALITY,
                        Scalr.Mode.FIT_TO_WIDTH, 640,
                        (int) ((originalImage.getHeight() / ((double) (originalImage.getWidth() / 700.0)))),
                        Scalr.OP_ANTIALIAS);
                ByteArrayOutputStream os = new ByteArrayOutputStream();
                ImageIO.write(origImage, extension, os);
                is = new ByteArrayInputStream(os.toByteArray());
            }

            //create thumbnail
            BufferedImage thumbnail = Scalr.resize(ImageIO.read(uf.getInputstream()), 150);
            ByteArrayOutputStream osThumb = new ByteArrayOutputStream();
            ImageIO.write(thumbnail, extension, osThumb);
            InputStream isThumbnail = new ByteArrayInputStream(osThumb.toByteArray());

            try (InputStream input = is) {
                Files.copy(input, file.toPath(), StandardCopyOption.REPLACE_EXISTING);
            }

            try (InputStream input = isThumbnail) {
                Files.copy(input, Paths.get(GlobalsBean.destThumbnail + GlobalsBean.separator + file.getName()),
                        StandardCopyOption.REPLACE_EXISTING);
            }

            //File chartFile = new File(file.getAbsolutePath());
            //chart = new DefaultStreamedContent(new FileInputStream(chartFile), "image/jpg");
            ImageBean ib = new ImageBean();
            ib.setFilename(file.getName());
            ib.setThumbFile(file.getName());
            ib.setImageFileLocation(GlobalsBean.destOriginal + GlobalsBean.separator + file.getName());
            imageList.add(ib);
        } catch (IOException | IllegalArgumentException | ImagingOpException ex) {
            Utilities.displayError(ex.getMessage());
        }
    }
}

From source file:com.ikanow.aleph2.security.utils.LdifExportUtil.java

public void exportToLdif(String outPath) {
    // copy Template
    Path pOutPath = Paths.get(outPath);

    try {//from   w w  w  . j av a2s . c o  m
        Files.copy(this.getClass().getResourceAsStream("aleph2_template.ldif"), pOutPath,
                StandardCopyOption.REPLACE_EXISTING);
        String userEntries = createUserEntries();

        Files.write(pOutPath, userEntries.getBytes(), StandardOpenOption.APPEND);
    } catch (Exception e) {
        logger.error(e);
    }
}

From source file:com.c4om.autoconf.ulysses.configanalyzer.configurationextractor.LocalCopyConfigurationsExtractor.java

/**
 * This method performs the extraction. 
 * The context must contain: //from   ww w. ja v a 2  s . c  o  m
 * <ul>
 * <li>One or more {@link ConfigureAppsTarget} returned by {@link ConfigurationAnalysisContext#getInputTargets()}. 
 * All the referenced {@link Application} must return "file://" URIs at {@link Application#getConfigurationURIs()}.</li>
 * <li>An {@link Environment} object returned by {@link ConfigurationAnalysisContext#getInputEnvironment()}, from which 
 * the configuration of the runtime where all the referenced applications are run.</li>
 * </ul>
 * @see com.c4om.autoconf.ulysses.interfaces.configanalyzer.configurationextractor.ConfigurationsExtractor#extractConfigurations(com.c4om.autoconf.ulysses.interfaces.configanalyzer.core.datastructures.ConfigurationAnalysisContext)
 */
@Override
public void extractConfigurations(ConfigurationAnalysisContext context)
        throws ConfigurationExtractionException {
    try {
        Path tempFolderPath = Files.createTempDirectory("ConfigurationAnalyzer");
        for (Target currentTarget : context.getInputTargets().values()) {
            if (!(currentTarget instanceof ConfigureAppsTarget)) {
                continue;
            }
            Properties configurationAnalyzerSettings = context.getConfigurationAnalyzerSettings();
            String runtimeConfigurationDirName = configurationAnalyzerSettings
                    .getProperty(PROPERTY_KEY_RUNTIME_CONFIGURATION_FILENAME);
            if (runtimeConfigurationDirName == null) {
                throw new ConfigurationExtractionException(
                        "Property '" + PROPERTY_KEY_RUNTIME_CONFIGURATION_FILENAME + "' not found");
            }
            ConfigureAppsTarget currentConfigureAppsTarget = (ConfigureAppsTarget) currentTarget;
            for (String appId : currentConfigureAppsTarget.getParameters().keySet()) {
                Path subfolderForApp = tempFolderPath.resolve(Paths.get(appId));
                List<File> copiedFiles = new ArrayList<>();
                Files.createDirectory(subfolderForApp);
                //We copy the application configuration files to the root of the directory.
                //We also copy the runtime configuration.
                Application currentApplication = (Application) currentConfigureAppsTarget.getParameters()
                        .get(appId);
                for (URI configurationURI : currentApplication.getConfigurationURIs()) {
                    //TODO: Let other configuration URIs live, specially, SVN-based ones, which should be extracted by other extractors. This would require some refactoring. 
                    if (!configurationURI.getScheme().equalsIgnoreCase("file")) {
                        throw new ConfigurationExtractionException(
                                "URI '" + configurationURI.toString() + "' does not have a 'file' scheme");
                    }
                    Path configurationPath = Paths.get(configurationURI);
                    Path configurationPathName = configurationPath.getFileName();
                    if (configurationPathName.toString().equals(runtimeConfigurationDirName)) {
                        throw new ConfigurationExtractionException(
                                "One of the application configuration files has the same name than the runtime configuration folder ('"
                                        + runtimeConfigurationDirName + "')");
                    }

                    Path destinationConfigurationPath = Files.copy(configurationPath,
                            subfolderForApp.resolve(configurationPathName), REPLACE_EXISTING);
                    File destinationConfigurationFile = destinationConfigurationPath.toFile();
                    copiedFiles.add(destinationConfigurationFile);

                }

                File runtimeConfigurationDirectory = new File(
                        context.getInputEnvironment().getApplicationConfigurations().get(appId));
                File destinationRuntimeConfigurationDirectory = subfolderForApp
                        .resolve(runtimeConfigurationDirName).toFile();
                FileUtils.copyDirectory(runtimeConfigurationDirectory,
                        destinationRuntimeConfigurationDirectory);
                copiedFiles.add(destinationRuntimeConfigurationDirectory);

                ExtractedConfiguration<File> extractedConfiguration = new FileExtractedConfiguration(appId,
                        currentTarget, copiedFiles);
                context.getExtractedConfigurations().add(extractedConfiguration);
            }
        }
    } catch (IOException e) {
        throw new ConfigurationExtractionException(e);
    }

}

From source file:org.eclipse.cdt.arduino.core.internal.board.Platform.java

public IStatus install(IProgressMonitor monitor) throws CoreException {
    try {/*from  w  ww . j av a2  s .  c  o  m*/
        try (CloseableHttpClient client = HttpClients.createDefault()) {
            HttpGet get = new HttpGet(url);
            try (CloseableHttpResponse response = client.execute(get)) {
                if (response.getStatusLine().getStatusCode() >= 400) {
                    return new Status(IStatus.ERROR, Activator.getId(),
                            response.getStatusLine().getReasonPhrase());
                } else {
                    HttpEntity entity = response.getEntity();
                    if (entity == null) {
                        return new Status(IStatus.ERROR, Activator.getId(), Messages.ArduinoBoardManager_1);
                    }
                    // the archive has the version number as the root
                    // directory
                    Path installPath = getInstallPath().getParent();
                    Files.createDirectories(installPath);
                    Path archivePath = installPath.resolve(archiveFileName);
                    Files.copy(entity.getContent(), archivePath, StandardCopyOption.REPLACE_EXISTING);

                    // extract
                    ArchiveInputStream archiveIn = null;
                    try {
                        String compressor = null;
                        String archiver = null;
                        if (archiveFileName.endsWith("tar.bz2")) { //$NON-NLS-1$
                            compressor = CompressorStreamFactory.BZIP2;
                            archiver = ArchiveStreamFactory.TAR;
                        } else if (archiveFileName.endsWith(".tar.gz") || archiveFileName.endsWith(".tgz")) { //$NON-NLS-1$ //$NON-NLS-2$
                            compressor = CompressorStreamFactory.GZIP;
                            archiver = ArchiveStreamFactory.TAR;
                        } else if (archiveFileName.endsWith(".tar.xz")) { //$NON-NLS-1$
                            compressor = CompressorStreamFactory.XZ;
                            archiver = ArchiveStreamFactory.TAR;
                        } else if (archiveFileName.endsWith(".zip")) { //$NON-NLS-1$
                            archiver = ArchiveStreamFactory.ZIP;
                        }

                        InputStream in = new BufferedInputStream(new FileInputStream(archivePath.toFile()));
                        if (compressor != null) {
                            in = new CompressorStreamFactory().createCompressorInputStream(compressor, in);
                        }
                        archiveIn = new ArchiveStreamFactory().createArchiveInputStream(archiver, in);

                        for (ArchiveEntry entry = archiveIn.getNextEntry(); entry != null; entry = archiveIn
                                .getNextEntry()) {
                            if (entry.isDirectory()) {
                                continue;
                            }

                            // TODO check for soft links in tar files.
                            Path entryPath = installPath.resolve(entry.getName());
                            Files.createDirectories(entryPath.getParent());
                            Files.copy(archiveIn, entryPath, StandardCopyOption.REPLACE_EXISTING);
                        }
                    } finally {
                        if (archiveIn != null) {
                            archiveIn.close();
                        }
                    }
                }
            }
        }
        return Status.OK_STATUS;
    } catch (IOException | CompressorException | ArchiveException e) {
        throw new CoreException(new Status(IStatus.ERROR, Activator.getId(), "Installing Platform", e));
    }
}

From source file:com.networknt.codegen.eventuate.EventuateHybridServiceGenerator.java

@Override
public void generate(String targetPath, Object model, Any config) throws IOException {
    // whoever is calling this needs to make sure that model is converted to Map<String, Object>
    String handlerPackage = config.get("handlerPackage").toString();
    boolean overwriteHandler = config.toBoolean("overwriteHandler");
    boolean overwriteHandlerTest = config.toBoolean("overwriteHandlerTest");
    boolean enableHttp = config.toBoolean("enableHttp");
    boolean enableHttps = config.toBoolean("enableHttps");
    boolean enableRegistry = config.toBoolean("enableRegistry");
    boolean supportClient = config.toBoolean("supportClient");
    String version = config.toString("version");

    transfer(targetPath, "", "pom.xml", templates.eventuate.hybrid.service.pom.template(config));
    //transfer(targetPath, "", "Dockerfile", templates.dockerfile.template(config));
    transfer(targetPath, "", ".gitignore", templates.eventuate.hybrid.gitignore.template());
    transfer(targetPath, "", "README.md", templates.eventuate.hybrid.service.README.template());
    transfer(targetPath, "", "LICENSE", templates.eventuate.hybrid.LICENSE.template());
    transfer(targetPath, "", ".classpath", templates.eventuate.hybrid.classpath.template());
    transfer(targetPath, "", ".project", templates.eventuate.hybrid.project.template());

    // config/*from  w w  w  . j  a  v a 2  s  .  c o m*/
    transfer(targetPath, ("src.main.resources.config").replace(".", separator), "service.yml",
            templates.eventuate.hybrid.serviceYml.template(config));

    transfer(targetPath, ("src.test.resources.config").replace(".", separator), "server.yml",
            templates.eventuate.hybrid.serverYml.template(
                    config.get("groupId") + "." + config.get("artifactId") + "-" + config.get("version"),
                    enableHttp, "49587", enableHttps, "49588", enableRegistry, version));
    transfer(targetPath, ("src.test.resources.config").replace(".", separator), "secret.yml",
            templates.eventuate.hybrid.secretYml.template());
    transfer(targetPath, ("src.test.resources.config").replace(".", separator), "hybrid-security.yml",
            templates.eventuate.hybrid.securityYml.template());

    if (supportClient) {
        transfer(targetPath, ("src.main.resources.config").replace(".", separator), "client.yml",
                templates.eventuate.hybrid.clientYml.template());
    } else {
        transfer(targetPath, ("src.test.resources.config").replace(".", separator), "client.yml",
                templates.eventuate.hybrid.clientYml.template());
    }

    transfer(targetPath, ("src.test.resources.config").replace(".", separator), "primary.crt",
            templates.eventuate.hybrid.primaryCrt.template());
    transfer(targetPath, ("src.test.resources.config").replace(".", separator), "secondary.crt",
            templates.eventuate.hybrid.secondaryCrt.template());

    // logging
    transfer(targetPath, ("src.main.resources").replace(".", separator), "logback.xml",
            templates.eventuate.hybrid.logback.template());
    transfer(targetPath, ("src.test.resources").replace(".", separator), "logback-test.xml",
            templates.eventuate.hybrid.logback.template());

    // handler
    Map<String, Object> services = new HashMap<String, Object>();
    Any anyModel = (Any) model;
    String host = anyModel.toString("host");
    String service = anyModel.toString("service");
    List<Any> items = anyModel.get("action").asList();
    if (items != null && items.size() > 0) {
        for (Any item : items) {
            Any any = item.get("example");
            String example = any.valueType() != ValueType.INVALID
                    ? StringEscapeUtils.escapeJson(any.toString()).trim()
                    : "";
            if (overwriteHandler)
                transfer(targetPath, ("src.main.java." + handlerPackage).replace(".", separator),
                        item.get("handler") + ".java", templates.eventuate.hybrid.handler
                                .template(handlerPackage, host, service, item, example));
            String serviceId = host + "/" + service + "/" + item.get("name") + "/" + item.get("version");
            Map<String, Object> map = new HashMap<>();
            map.put("schema", item.get("schema"));
            map.put("scope", item.get("scope"));
            services.put(serviceId, map);
        }

        // handler test cases
        transfer(targetPath, ("src.test.java." + handlerPackage + ".").replace(".", separator),
                "TestServer.java", templates.eventuate.hybrid.testServer.template(handlerPackage));
        if (overwriteHandlerTest) {
            for (Any item : items) {
                transfer(targetPath, ("src.test.java." + handlerPackage).replace(".", separator),
                        item.get("handler") + "Test.java",
                        templates.eventuate.hybrid.handlerTest.template(handlerPackage, host, service, item));
            }
        }
    }

    // transfer binary files without touching them.
    try (InputStream is = EventuateHybridServiceGenerator.class
            .getResourceAsStream("/binaries/server.keystore")) {
        Files.copy(is,
                Paths.get(targetPath, ("src.test.resources.config").replace(".", separator), "server.keystore"),
                StandardCopyOption.REPLACE_EXISTING);
    }
    try (InputStream is = EventuateHybridServiceGenerator.class
            .getResourceAsStream("/binaries/server.truststore")) {
        Files.copy(is, Paths.get(targetPath, ("src.test.resources.config").replace(".", separator),
                "server.truststore"), StandardCopyOption.REPLACE_EXISTING);
    }

    if (Files.notExists(Paths.get(targetPath, ("src.main.resources.config").replace(".", separator)))) {
        Files.createDirectories(Paths.get(targetPath, ("src.main.resources.config").replace(".", separator)));
    }
    // write the generated schema into the config folder for schema validation.
    JsonStream.serialize(services, new FileOutputStream(FileSystems.getDefault()
            .getPath(targetPath, ("src.main.resources").replace(".", separator), "schema.json").toFile()));
}

From source file:com.networknt.codegen.hybrid.HybridServiceGenerator.java

@Override
public void generate(String targetPath, Object model, Any config) throws IOException {
    // whoever is calling this needs to make sure that model is converted to Map<String, Object>
    String handlerPackage = config.get("handlerPackage").toString();
    boolean overwriteHandler = config.toBoolean("overwriteHandler");
    boolean overwriteHandlerTest = config.toBoolean("overwriteHandlerTest");
    boolean enableHttp = config.toBoolean("enableHttp");
    boolean enableHttps = config.toBoolean("enableHttps");
    boolean enableRegistry = config.toBoolean("enableRegistry");
    boolean supportClient = config.toBoolean("supportClient");
    String version = config.toString("version");

    transfer(targetPath, "", "pom.xml", templates.hybrid.service.pom.template(config));
    //transfer(targetPath, "", "Dockerfile", templates.dockerfile.template(config));
    transfer(targetPath, "", ".gitignore", templates.hybrid.gitignore.template());
    transfer(targetPath, "", "README.md", templates.hybrid.service.README.template());
    transfer(targetPath, "", "LICENSE", templates.hybrid.LICENSE.template());
    transfer(targetPath, "", ".classpath", templates.hybrid.classpath.template());
    transfer(targetPath, "", ".project", templates.hybrid.project.template());

    // config//from   w w  w  .ja va  2 s .co  m
    transfer(targetPath, ("src.test.resources.config").replace(".", separator), "service.yml",
            templates.hybrid.serviceYml.template(config));

    transfer(targetPath, ("src.test.resources.config").replace(".", separator), "server.yml",
            templates.hybrid.serverYml.template(
                    config.get("groupId") + "." + config.get("artifactId") + "-" + config.get("version"),
                    enableHttp, "49587", enableHttps, "49588", enableRegistry, version));
    transfer(targetPath, ("src.test.resources.config").replace(".", separator), "secret.yml",
            templates.hybrid.secretYml.template());
    transfer(targetPath, ("src.test.resources.config").replace(".", separator), "hybrid-security.yml",
            templates.hybrid.securityYml.template());
    transfer(targetPath, ("src.test.resources.config").replace(".", separator), "client.yml",
            templates.hybrid.clientYml.template());
    transfer(targetPath, ("src.test.resources.config").replace(".", separator), "primary.crt",
            templates.hybrid.primaryCrt.template());
    transfer(targetPath, ("src.test.resources.config").replace(".", separator), "secondary.crt",
            templates.hybrid.secondaryCrt.template());

    // logging
    transfer(targetPath, ("src.main.resources").replace(".", separator), "logback.xml",
            templates.hybrid.logback.template());
    transfer(targetPath, ("src.test.resources").replace(".", separator), "logback-test.xml",
            templates.hybrid.logback.template());

    // handler
    Map<String, Object> services = new HashMap<String, Object>();
    Any anyModel = (Any) model;
    String host = anyModel.toString("host");
    String service = anyModel.toString("service");
    List<Any> items = anyModel.get("action").asList();
    if (items != null && items.size() > 0) {
        for (Any item : items) {
            Any any = item.get("example");
            String example = any.valueType() != ValueType.INVALID
                    ? StringEscapeUtils.escapeJson(any.toString()).trim()
                    : "";
            if (!overwriteHandler
                    && checkExist(targetPath, ("src.main.java." + handlerPackage).replace(".", separator),
                            item.get("handler") + ".java")) {
                continue;
            }
            transfer(targetPath, ("src.main.java." + handlerPackage).replace(".", separator),
                    item.get("handler") + ".java",
                    templates.hybrid.handler.template(handlerPackage, host, service, item, example));
            String serviceId = host + "/" + service + "/" + item.get("name") + "/" + item.get("version");
            Map<String, Object> map = new HashMap<>();
            map.put("schema", item.get("schema"));
            map.put("scope", item.get("scope"));
            services.put(serviceId, map);
        }

        // handler test cases
        transfer(targetPath, ("src.test.java." + handlerPackage + ".").replace(".", separator),
                "TestServer.java", templates.hybrid.testServer.template(handlerPackage));
        for (Any item : items) {
            if (!overwriteHandlerTest
                    && checkExist(targetPath, ("src.test.java." + handlerPackage).replace(".", separator),
                            item.get("handler") + "Test.java")) {
                continue;
            }
            transfer(targetPath, ("src.test.java." + handlerPackage).replace(".", separator),
                    item.get("handler") + "Test.java",
                    templates.hybrid.handlerTest.template(handlerPackage, host, service, item));
        }
    }

    // transfer binary files without touching them.
    try (InputStream is = HybridServiceGenerator.class.getResourceAsStream("/binaries/server.keystore")) {
        Files.copy(is,
                Paths.get(targetPath, ("src.test.resources.config").replace(".", separator), "server.keystore"),
                StandardCopyOption.REPLACE_EXISTING);
    }
    try (InputStream is = HybridServiceGenerator.class.getResourceAsStream("/binaries/server.truststore")) {
        Files.copy(is, Paths.get(targetPath, ("src.test.resources.config").replace(".", separator),
                "server.truststore"), StandardCopyOption.REPLACE_EXISTING);
    }

    if (Files.notExists(Paths.get(targetPath, ("src.main.resources.config").replace(".", separator)))) {
        Files.createDirectories(Paths.get(targetPath, ("src.main.resources.config").replace(".", separator)));
    }
    // write the generated schema into the config folder for schema validation.
    JsonStream.serialize(services, new FileOutputStream(FileSystems.getDefault()
            .getPath(targetPath, ("src.main.resources").replace(".", separator), "schema.json").toFile()));
}