Example usage for org.apache.commons.lang3 StringUtils join

List of usage examples for org.apache.commons.lang3 StringUtils join

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils join.

Prototype

public static String join(final Iterable<?> iterable, final String separator) 

Source Link

Document

Joins the elements of the provided Iterable into a single String containing the provided elements.

No delimiter is added before or after the list.

Usage

From source file:com.deploymentio.cfnstacker.template.VelocityUtil.java

public static String joinLinesWithSingleQuote(String content) {
    String[] lines = StringUtils.split(content, "\r\n");
    for (int i = 0; i < lines.length; i++) {
        lines[i] = "'" + lines[i].replace("\\\"", "\\\\\"") + "\\n'";
    }//  w  ww .  j a  va 2s. co m
    return StringUtils.join(lines, " +\n");
}

From source file:com.ijuru.kumva.util.Utils.java

/**
 * Makes a CSV string from a collection of objects
 * @param vals the objects//from  w w w  .ja  v  a 2s  .co  m
 * @return the CSV string
 */
public static String makeCSV(Collection<?> vals) {
    return StringUtils.join(vals, ", ");
}

From source file:de.micromata.mgc.application.webserver.config.KeyTool.java

public static void generateKey(ValContext ctx, File keyFile, String storePass, String keyAlias) {
    String[] args = { "keytool", "-genkey", "-alias", keyAlias, "-keyalg", "RSA", "-keystore",
            keyFile.getAbsolutePath(), "-keysize", "2048", "-keypass", storePass, "-storepass", storePass,
            "-dname", "cn=Launcher, ou=MGC, o=Microamta, c=DE" };
    StringBuilder oksb = new StringBuilder();
    oksb.append("Execute: " + StringUtils.join(args, " "));
    try {/* ww  w . j  a  v a2  s .c  om*/
        ProcessBuilder pb = new ProcessBuilder(args);
        pb.redirectErrorStream(true);
        Process process = pb.start();
        InputStream is = process.getInputStream();
        InputStreamReader isr = new InputStreamReader(is);
        BufferedReader br = new BufferedReader(isr);
        String line;
        while ((line = br.readLine()) != null) {
            oksb.append(line);
        }
        boolean success = process.waitFor(5, TimeUnit.SECONDS);
        if (success == false) {
            ctx.directError(null, "Fail to wait for keytool");
        } else {
            int exitValue = process.exitValue();
            if (exitValue == 0) {
                oksb.append("\nSuccess");
                ctx.directInfo(null, oksb.toString());
            } else {
                ctx.directError(null, oksb.toString());
                ctx.directError(null, "Failure executing keytool. ReturnCode: " + exitValue);
            }
        }
    } catch (Exception ex) {
        ctx.directError(null, "Failure executing keytool: " + ex.getMessage(), ex);
    }
}

From source file:com.github.riccardove.easyjasub.commons.CommonsLangStringUtils.java

public static String charListToString(Iterable<Character> japaneseChars) {
    return StringUtils.join(japaneseChars, "");
}

From source file:me.bramhaag.discordselfbot.util.Util.java

/**
 * Combine {@code args}.//from www .  j a v  a 2  s. c  o m
 * @param args {@code String[]} to combine.
 * @return combined {@code args}.
 */
@NonNull
public static String combineArgs(@NonNull String[] args) {
    return StringUtils.join(args, ' ');
}

From source file:com.ijuru.ijambo.Utils.java

/**
 * Scrambles the letters of a word. Shuffles the word twice and returns
 * the result with the highest levenshtein distance from the original
 * @param word the word//from  w ww .j ava2  s  .co m
 * @return the scrambled word
 */
public static String scrambleWord(String word) {
    List<String> chars1 = Arrays.asList(word.split(""));
    List<String> chars2 = new ArrayList<String>(chars1);

    Collections.shuffle(chars1);
    Collections.shuffle(chars2);

    String scramble1 = StringUtils.join(chars1, "");
    String scramble2 = StringUtils.join(chars2, "");

    int dist1 = StringUtils.getLevenshteinDistance(word, scramble1);
    int dist2 = StringUtils.getLevenshteinDistance(word, scramble2);

    return (dist1 > dist2) ? scramble1 : scramble2;
}

From source file:com.slothpetrochemical.bridgeprob.BridgeProblemSignature.java

static String composeSignature(final BridgeProblemStateDescriptor descriptor) {
    StringBuilder sb = new StringBuilder();
    boolean flashlightOnLeft = descriptor.isFlashlightOnLeft();
    sb.append(StringUtils.join(descriptor.getNamesOnLeft(), NAME_DELIMITER));
    if (flashlightOnLeft) {
        sb.append(FLASHLIGHT);//www.  j  a va2s .c  o m
    }
    sb.append(BRIDGE_DELIMITER);
    sb.append(StringUtils.join(descriptor.getNamesOnRight(), NAME_DELIMITER));
    if (!flashlightOnLeft) {
        sb.append(FLASHLIGHT);
    }
    return sb.toString();
}

From source file:hello.batch.HelloBatch.java

public void sayHello() {
    System.out.println(StringUtils.join(helloMessager.getMessage("taro"), "!"));
}

From source file:SignatureTest.java

private String findSignature(String str) {
    String[] els = StringUtils.split(str, ":");
    Arrays.sort(els);/*from  w ww.j a v  a  2  s . com*/
    return StringUtils.join(els, ":");
}

From source file:net.packet.pojo.Error.java

public String getAllErrors() {
    String allErrors = StringUtils.join(errors, ",\n");
    if (StringUtils.isNotBlank(error)) {
        allErrors = error + ",\n" + allErrors;
    }//  w  w w  . j av a2 s.  c  om
    return allErrors;
}