Example usage for java.lang System lineSeparator

List of usage examples for java.lang System lineSeparator

Introduction

In this page you can find the example usage for java.lang System lineSeparator.

Prototype

String lineSeparator

To view the source code for java.lang System lineSeparator.

Click Source Link

Usage

From source file:com.tc.server.CommandLineParser.java

private static void printHelp(ConfigurationProvider configurationProvider) {
    new HelpFormatter().printHelp("[start-tc-server.sh|bat] [options]", "Options: " + System.lineSeparator(),
            createOptions(), "");
    System.out.println(configurationProvider.getConfigurationParamsDescription());
}

From source file:io.druid.metadata.storage.mysql.MySQLConnector.java

@Override
public boolean tableExists(Handle handle, String tableName) {
    // ensure database defaults to utf8, otherwise bail
    boolean isUtf8 = handle
            .createQuery("SHOW VARIABLES where variable_name = 'character_set_database' and value = 'utf8'")
            .list().size() == 1;//from   w  ww .j a  va  2  s.  com

    if (!isUtf8) {
        throw new ISE("Database default character set is not UTF-8." + System.lineSeparator()
                + "  Druid requires its MySQL database to be created using UTF-8 as default character set."
                + " If you are upgrading from Druid 0.6.x, please make all tables have been converted to utf8 and change the database default."
                + " For more information on how to convert and set the default, please refer to section on updating from 0.6.x in the Druid 0.7.1 release notes.");
    }

    return !handle.createQuery("SHOW tables LIKE :tableName").bind("tableName", tableName).list().isEmpty();
}

From source file:com.blackducksoftware.integration.hub.docker.executor.Executor.java

public String[] executeCommand(final String commandString)
        throws IOException, InterruptedException, HubIntegrationException {
    final List<String> commandStringList = Arrays.asList(commandString.split(" "));
    final ProcessBuilder builder = new ProcessBuilder();
    builder.command(commandStringList.toArray(new String[commandStringList.size()]));
    builder.directory(new File("."));
    final Process process = builder.start();
    final boolean finished = process.waitFor(this.commandTimeout, TimeUnit.MILLISECONDS);
    if (!finished) {
        throw new HubIntegrationException(String.format(
                "Execution of command %s timed out (timeout: %d milliseconds)", commandString, commandTimeout));
    }/*  w  ww .  j a  va 2  s  .  com*/
    final int errCode = process.exitValue();
    if (errCode == 0) {
        logger.debug(String.format("Execution of command: %s: Succeeded", commandString));
    } else {
        throw new HubIntegrationException(
                String.format("Execution of command: %s: Error code: %d", commandString, errCode));
    }
    final InputStream inputStream = process.getInputStream();
    final String outputString = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
    logger.debug(String.format("Command output:/n%s", outputString));
    return outputString.split(System.lineSeparator());
}

From source file:org.smigo.log.LogController.java

@RequestMapping(value = { "/rest/log/feature/*", "/rest/log/feature" }, method = RequestMethod.POST)
@ResponseBody//from w  ww. j  a va 2 s .c o  m
public void logFeatureRequest(@RequestBody FeatureRequest feature, HttpServletRequest request,
        HttpServletResponse response) {
    mailHandler.sendAdminNotification("feature request",
            feature.getFeature() + logHandler.getRequestDump(request, response, System.lineSeparator()));
}

From source file:com.bc.fiduceo.matchup.MatchupToolTest.java

@Before
public void SetUp() {
    ls = System.lineSeparator();
}

From source file:com.liferay.blade.cli.command.CreateCommand.java

@Override
public void execute() throws Exception {
    CreateArgs createArgs = getArgs();//  w ww .j  ava 2  s. c o  m
    BladeCLI bladeCLI = getBladeCLI();

    if (createArgs.isListTemplates()) {
        _printTemplates();

        return;
    }

    String template = createArgs.getTemplate();

    if (template == null) {
        bladeCLI.error("The following option is required: [-t | --template]\n\n");
        bladeCLI.error("Availble project templates:\n\n");

        _printTemplates();

        return;
    } else if (template.equals("service")) {
        if (createArgs.getService() == null) {
            StringBuilder sb = new StringBuilder();

            sb.append("\"-t service <FQCN>\" parameter missing.");
            sb.append(System.lineSeparator());
            sb.append("Usage: blade create -t service -s <FQCN> <project name>");
            sb.append(System.lineSeparator());

            bladeCLI.error(sb.toString());

            return;
        }
    } else if (template.equals("fragment")) {
        boolean hasHostBundleBSN = false;

        if (createArgs.getHostBundleBSN() != null) {
            hasHostBundleBSN = true;
        }

        boolean hasHostBundleVersion = false;

        if (createArgs.getHostBundleVersion() != null) {
            hasHostBundleVersion = true;
        }

        if (!hasHostBundleBSN || !hasHostBundleVersion) {
            StringBuilder sb = new StringBuilder("\"-t fragment\" options missing:" + System.lineSeparator());

            if (!hasHostBundleBSN) {
                sb.append("Host Bundle BSN (\"-h\", \"--host-bundle-bsn\") is required.");
                sb.append(System.lineSeparator());
            }

            if (!hasHostBundleVersion) {
                sb.append("Host Bundle Version (\"-H\", \"--host-bundle-version\") is required.");
                sb.append(System.lineSeparator());
            }

            bladeCLI.printUsage("create", sb.toString());

            return;
        }
    } else if (template.equals("modules-ext")) {
        if ("maven".equals(createArgs.getProfileName())) {
            bladeCLI.error(
                    "Modules Ext projects are not supported with Maven build. Please use Gradle build instead.");

            return;
        }

        boolean hasOriginalModuleName = false;

        if (createArgs.getOriginalModuleName() != null) {
            hasOriginalModuleName = true;
        }

        if (!hasOriginalModuleName) {
            StringBuilder sb = new StringBuilder();

            sb.append("modules-ext options missing:");
            sb.append(System.lineSeparator());
            sb.append("\"-m\", \"--original-module-name\") is required.");
            sb.append(System.lineSeparator());
            sb.append(
                    "\"-M\", \"--original-module-version\") is required unless you have enabled target platform.");
            sb.append(System.lineSeparator());
            sb.append(System.lineSeparator());

            bladeCLI.printUsage("create", sb.toString());

            return;
        }
    }

    String name = createArgs.getName();

    if (BladeUtil.isEmpty(name)) {
        _addError("Create", "SYNOPSIS\n\t create [options] <[name]>");

        return;
    }

    if (!_isExistingTemplate(template)) {
        _addError("Create", "The template " + template + " is not in the list");

        return;
    }

    File dir;

    File argsDir = createArgs.getDir();

    if (argsDir != null) {
        dir = new File(argsDir.getAbsolutePath());
    } else if (template.startsWith("war") || template.equals("theme") || template.equals("layout-template")
            || template.equals("spring-mvc-portlet")) {

        dir = _getDefaultWarsDir();
    } else if (template.startsWith("modules-ext")) {
        dir = _getDefaultExtDir();
    } else {
        dir = _getDefaultModulesDir();
    }

    final File checkDir = new File(dir, name);

    if (!_checkDir(checkDir)) {
        _addError("Create", name + " is not empty or it is a file. Please clean or delete it then run again");

        return;
    }

    ProjectTemplatesArgs projectTemplatesArgs = getProjectTemplateArgs(createArgs, bladeCLI, template, name,
            dir);

    List<File> archetypesDirs = projectTemplatesArgs.getArchetypesDirs();

    Path customTemplatesPath = bladeCLI.getExtensionsPath();

    archetypesDirs.add(customTemplatesPath.toFile());

    execute(projectTemplatesArgs);

    Path path = dir.toPath();

    Path absolutePath = path.toAbsolutePath();

    absolutePath = absolutePath.normalize();

    bladeCLI.out("Successfully created project " + projectTemplatesArgs.getName() + " in " + absolutePath);
}

From source file:iics.Connection.java

String readfile() {

    String link = "";
    try {//ww  w  .j  a  va 2  s  .co m
        try (BufferedReader br = new BufferedReader(new FileReader(f1.getAbsoluteFile()))) {
            StringBuilder sb = new StringBuilder();
            String line = br.readLine();

            while (line != null) {
                sb.append(line);
                sb.append(System.lineSeparator());
                line = br.readLine();
            }
            link = sb.toString();
            // System.out.println("files "+link);
        }
    } catch (Exception ex) {
        JOptionPane.showMessageDialog(null,
                "                 An error occured!! \n Contact your system admin for help.", null,
                JOptionPane.WARNING_MESSAGE);
        close_loda();
    }
    return link;
}

From source file:com.amazonaws.services.kinesis.multilang.MessageWriter.java

/**
 * Writes the message then writes the line separator provided by the system. Flushes each message to guarantee it
 * is delivered as soon as possible to the subprocess.
 * /*from w  w w . jav a  2  s  . com*/
 * @param message A message to be written to the subprocess.
 * @return
 * @throws IOException
 */
private Future<Boolean> writeMessageToOutput(final String message) throws IOException {
    Callable<Boolean> writeMessageToOutputTask = new Callable<Boolean>() {
        public Boolean call() throws Exception {
            try {
                /*
                 * If the message size exceeds the size of the buffer, the write won't be guaranteed to be atomic,
                 * so we synchronize on the writer to avoid interlaced lines from different calls to this method.
                 */
                synchronized (writer) {
                    writer.write(message, 0, message.length());
                    writer.write(System.lineSeparator(), 0, System.lineSeparator().length());
                    writer.flush();
                }
                LOG.info("Message size == " + message.getBytes().length + " bytes for shard " + shardId);
            } catch (IOException e) {
                open = false;
            }
            return open;
        }
    };

    if (open) {
        return this.executorService.submit(writeMessageToOutputTask);
    } else {
        String errorMessage = "Cannot write message " + message + " because writer is closed for shard "
                + shardId;
        LOG.info(errorMessage);
        throw new IllegalStateException(errorMessage);
    }
}

From source file:io.knotx.launcher.KnotxStarterVerticle.java

private StringBuilder collectDeployment(StringBuilder accumulator, Pair<String, String> deploymentId) {
    return accumulator
            .append(String.format("\t\tDeployed %s [%s]", deploymentId.getRight(), deploymentId.getLeft()))
            .append(System.lineSeparator());
}

From source file:com.blackducksoftware.integration.hub.detect.help.print.HelpTextWriter.java

private String formatColumns(final List<String> columns, final int... columnWidths) {
    final StringBuilder createColumns = new StringBuilder();
    final List<String> columnfirstRow = new ArrayList<>();
    final List<String> columnRemainingRows = new ArrayList<>();
    for (int i = 0; i < columns.size(); i++) {
        if (columns.get(i).length() < columnWidths[i]) {
            columnfirstRow.add(columns.get(i));
            columnRemainingRows.add("");
        } else {/*www.j a  va 2  s  .com*/
            final String firstRow = columns.get(i).substring(0, columnWidths[i]);
            int endOfWordIndex = firstRow.lastIndexOf(' ');
            if (endOfWordIndex == -1) {
                endOfWordIndex = columnWidths[i] - 1;
                columnfirstRow.add(firstRow.substring(0, endOfWordIndex) + " ");
            } else {
                columnfirstRow.add(firstRow.substring(0, endOfWordIndex));
            }

            columnRemainingRows.add(columns.get(i).substring(endOfWordIndex).trim());
        }
    }

    for (int i = 0; i < columnfirstRow.size(); i++) {
        createColumns.append(StringUtils.rightPad(columnfirstRow.get(i), columnWidths[i], " "));
    }

    if (!allColumnsEmpty(columnRemainingRows)) {
        createColumns.append(System.lineSeparator() + formatColumns(columnRemainingRows, columnWidths));
    }
    return createColumns.toString();
}