Example usage for java.lang String concat

List of usage examples for java.lang String concat

Introduction

In this page you can find the example usage for java.lang String concat.

Prototype

public String concat(String str) 

Source Link

Document

Concatenates the specified string to the end of this string.

Usage

From source file:gov.nih.nci.ispy.util.MoreStringUtils.java

/**
 * This method will take a string of characters that you do not want to
 * appear in your string.  It will remove the unallowed characters and then
 * return to you the string as it would be without those characters.  For
 * instance if you passed ":" as the unallowed characters, and "I a:m ::Cle:an"
 * is the string you passed, you would end up with "I am Clean".  It does 
 * not replace the characters it removes them.
 * //from   w  w w . j  a  v a 2  s  .  c om
 * @param unallowableCharString --give me a string of all the chars you don't want in your
 * final string.
 * @param stringToClean  --this is the string that you want cleaned
 * @return  your new string
 */
public static String cleanString(String unallowableCharacters, String stringToClean) {
    if (unallowableCharacters != null && stringToClean != null) {
        char[] filterString = unallowableCharacters.toCharArray();
        filterString = stringToClean.toCharArray();
        stringToClean = "";
        for (int i = 0; i < filterString.length; i++) {
            if (unallowableCharacters.indexOf(filterString[i]) == -1) {
                stringToClean = stringToClean.concat(Character.toString(filterString[i]));
            }
        }
    }
    return stringToClean;
}

From source file:com.photon.phresco.framework.win8.util.Win8MetroCofigFileParser.java

private static File replacePath(String string, File dir, ApplicationInfo info) {
    File newFile = new File("");
    File oldFile = new File("");
    if (string.contains(HELLOWORLD) || string.startsWith(HELLOWORLD) || string.startsWith(info.getName())
            || string.contains(info.getName())) {
        oldFile = new File(dir + File.separator + string);
        String substring = info.getName();
        if (string.contains(HELLOWORLD)) {
            substring = string.substring(0, 10).replace(HELLOWORLD, info.getName());
            String substring2 = string.substring(10, string.length());
            newFile = new File(dir + File.separator + substring.concat(substring2));
        } else {/* w  w w .  j  a v a  2s .  co  m*/
            newFile = new File(dir + File.separator + substring);
        }
        oldFile.renameTo(newFile);
    }
    return newFile;
}

From source file:com.streamsets.pipeline.lib.el.StringEL.java

@ElFunction(prefix = "str", name = "concat", description = "Returns a new string that is a concatenation of the two argument strings.")
public static String concat(@ElParam("string1") String string1, @ElParam("string2") String string2) {
    string1 = (string1 == null) ? "" : string1;
    string2 = (string2 == null) ? "" : string2;
    return string1.concat(string2);
}

From source file:com.iiitd.networking.UDPMessenger.java

public static String ipToString(int ip, boolean broadcast) {
    String result = new String();

    Integer[] address = new Integer[4];
    for (int i = 0; i < 4; i++)
        address[i] = (ip >> 8 * i) & 0xFF;
    for (int i = 0; i < 4; i++) {
        if (i != 3)
            result = result.concat(address[i] + ".");
        else/*from ww  w  . j ava  2s  .co  m*/
            result = result.concat("255.");
    }
    return result.substring(0, result.length() - 2);
}

From source file:es.bsc.autonomic.powermodeller.configuration.CoreConfiguration.java

public static String getFilePath(String configFile) {
    String pmgHome = PMG_HOME;
    if (pmgHome == null) {
        pmgHome = PMG_HOME_DEFAULT;/* www  .  j a va 2 s  .c o m*/
        PMG_HOME = pmgHome;
        logger.warn("Please set environment variable PMG_HOME. Using default " + pmgHome);
    }

    File fileObject = new File(pmgHome.concat(configFile));
    if (!fileObject.exists()) {
        try {
            createDefaultConfigFile(fileObject);
        } catch (Exception ex) {
            logger.error("Error reading " + pmgHome.concat(configFile) + " configuration file: ", ex);
        }
    }

    return pmgHome.concat(configFile);
}

From source file:org.fiware.apps.repository.it.collectionService.CollectionServiceGetITTest.java

@BeforeClass
public static void setUpClass() throws IOException {
    IntegrationTestHelper client = new IntegrationTestHelper();

    String fileName = "fileNameExample";
    String contentUrl = "http://localhost:8080/contentUrl/resourceTestGet";
    String creator = "Me";
    String name = "resourceTest";
    Resource resource = IntegrationTestHelper.generateResource(null, fileName, null, contentUrl, null, creator,
            null, null, name);//www . j a  v  a  2 s  .c  o m

    String auxString = "";
    FileReader file = new FileReader("src/test/resources/rdf+xml.rdf");
    BufferedReader buffer = new BufferedReader(file);
    while (buffer.ready()) {
        auxString = auxString.concat(buffer.readLine());
    }
    buffer.close();
    rdfxmlExample = auxString;

    //Delete the collection
    List<Header> headers = new LinkedList<>();
    client.deleteCollection(collection, headers);

    //Create a resource in the repository
    headers.add(new BasicHeader("Content-Type", "application/json"));
    HttpResponse response = client.postResourceMeta(collection, client.resourceToJson(resource), headers);
    assertEquals(201, response.getStatusLine().getStatusCode());

    //Insert RDF content in the resource
    headers = new LinkedList<>();
    headers.add(new BasicHeader("Content-Type", "application/rdf+xml"));
    response = client.putResourceContent(collection + "/" + name, rdfxmlExample, headers);
    assertEquals(200, response.getStatusLine().getStatusCode());
}

From source file:com.example.igorklimov.popularmoviesdemo.helpers.Utility.java

@NonNull
public static String formatBudget(String format) {
    String result = "";
    int j = format.length();
    for (int i = j - 1; i >= 0; i--) {
        result = result.concat(format.charAt(i) + "");
        if ((j - i) % 3 == 0 && i != 0)
            result = result.concat(",");
    }// w  w w . ja v a2  s.c o  m
    format = "";
    for (int i = result.length() - 1; i >= 0; i--) {
        format = format.concat(result.charAt(i) + "");
    }
    return format;
}

From source file:com.bw.hawksword.wiktionary.ExtendedWikiHelper.java

/**
 * Format the given wiki-style text into formatted HTML content. This will
 * create headers, lists, internal links, and style formatting for any wiki
 * markup found./*from  w w  w .  ja va2  s.  c o  m*/
 *
 * @param wikiText The raw text to format, with wiki-markup included.
 * @return HTML formatted content, ready for display in {@link WebView}.
 */
public static String formatWikiText(String wikiText) {
    if (wikiText == null) {
        return null;
    }

    // Insert a fake last section into the document so our section splitter
    // can correctly catch the last section.
    wikiText = wikiText.concat(STUB_SECTION);

    // Read through all sections, keeping only those matching our filter,
    // and only including the first entry for each title.
    HashSet<String> foundSections = new HashSet<String>();
    StringBuilder builder = new StringBuilder();

    Matcher sectionMatcher = sSectionSplit.matcher(wikiText);
    while (sectionMatcher.find()) {
        String title = sectionMatcher.group(1);
        if (!foundSections.contains(title) && sValidSections.matcher(title).matches()) {
            String sectionContent = sectionMatcher.group();
            foundSections.add(title);
            builder.append(sectionContent);
        }
    }

    // Our new wiki text is the selected sections only
    wikiText = builder.toString();

    // Apply all formatting rules, in order, to the wiki text
    for (FormatRule rule : sFormatRules) {
        wikiText = rule.apply(wikiText);
    }

    // Return the resulting HTML with style sheet, if we have content left
    if (!TextUtils.isEmpty(wikiText)) {
        return STYLE_SHEET + wikiText;
    } else {
        return null;
    }
}

From source file:Main.java

/**
 * <p>Right pad a String with a specified character.</p>
 *
 * <p>The String is padded to the size of <code>size</code>.</p>
 *
 * <pre>/*from   www.ja v a2s  .  co m*/
 * StringUtils.rightPad(null, *, *)     = null
 * StringUtils.rightPad("", 3, 'z')     = "zzz"
 * StringUtils.rightPad("bat", 3, 'z')  = "bat"
 * StringUtils.rightPad("bat", 5, 'z')  = "batzz"
 * StringUtils.rightPad("bat", 1, 'z')  = "bat"
 * StringUtils.rightPad("bat", -1, 'z') = "bat"
 * </pre>
 *
 * @param str  the String to pad out, may be null
 * @param size  the size to pad to
 * @param padChar  the character to pad with
 * @return right padded String or original String if no padding is necessary,
 *  <code>null</code> if null String input
 * @since 2.0
 */
public static String rightPad(String str, int size, char padChar) {
    if (str == null) {
        return null;
    }
    int pads = size - str.length();
    if (pads <= 0) {
        return str; // returns original String when possible
    }
    if (pads > PAD_LIMIT) {
        return rightPad(str, size, String.valueOf(padChar));
    }
    return str.concat(padding(pads, padChar));
}

From source file:org.fiware.apps.repository.it.IntegrationTestHelper.java

public static String collectionToJson(ResourceCollection collection) {
    String collectionString = "{\n";
    if (collection.getCreationDate() != null) {
        collectionString = collectionString
                .concat("\"creationDate\" : \"" + collection.getCreationDate().toString() + "\",\n");
    }//from   w  w  w  .j a v  a  2s . c o m
    if (collection.getCreator() != null) {
        collectionString = collectionString.concat("\"creator\" : \"" + collection.getCreator() + "\",\n");
    }
    if (collection.getId() != null) {
        collectionString = collectionString.concat("\"id\" : \"" + collection.getId() + "\",\n");
    }
    if (collection.getModificationDate() != null) {
        collectionString = collectionString
                .concat("\"modificationDate\" : \"" + collection.getModificationDate().toString() + "\",\n");
    }
    if (collection.getName() != null) {
        collectionString = collectionString.concat("\"name\" : \"" + collection.getName() + "\",\n");
    }
    collectionString = collectionString.concat("\"type\" : \"collection\"\n");
    return collectionString.concat("\n}");
}