Example usage for java.lang String replace

List of usage examples for java.lang String replace

Introduction

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

Prototype

public String replace(CharSequence target, CharSequence replacement) 

Source Link

Document

Replaces each substring of this string that matches the literal target sequence with the specified literal replacement sequence.

Usage

From source file:Main.java

public static void main(String[] args) {
    String str = "abc";

    str = str.replace('b', 'd');

    System.out.println(str);/*from   www  .  j  av  a 2s. c o m*/
}

From source file:Main.java

public static void main(String args[]) {
    String myString = "'''";
    String tmpString = myString.replace('\'', '*');
    System.out.println("Original = " + myString);
    System.out.println("Result   = " + tmpString);
}

From source file:Main.java

public static void main(String[] args) {
    String oldStr = new String("tooth");
    String newStr = oldStr.replace('o', 'e');
    System.out.println(newStr);//from ww  w .  j  a va  2s  .  c  o m
}

From source file:Main.java

public static void main(String args[]) {

    String str = "This is a test.";

    System.out.println(str.replace('T', 'A'));
}

From source file:Main.java

public static void main(String[] args) {
    String text = "The quick brown fox jumps over the lazy dog";

    text = text.replace('o', 'u');
    System.out.println("Result: " + text);
}

From source file:Main.java

public static void main(String[] arg) {
    String text = "To be or not to be, that is the question.";
    String newText = text.replace(' ', '/');

    System.out.println(newText);/*  ww w  .j  a v a2 s.co  m*/
}

From source file:MainClass.java

public static void main(String[] arg) {
    String text = "To be or not to be, that is the question.";
    String newText = text.replace(' ', '/'); // Modify the string text

    System.out.println(newText);// ww w  .  j a  v a 2  s  . c o m
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    String string = "this is a string";
    // Replace all occurrences of 'a' with 'o'
    String newString = string.replace('a', 'o');
    System.out.println(newString);
}

From source file:ClientServicesQA.java

public static void main(String[] args) throws Exception {
    // TODO Auto-generated method stub
    String id = "LNWS-AM38-12M9";
    id = id.replace("-", "");
    System.out.println(id);//  w  w w.  j  a v a2s.c  om

    byte[] bytes = {};
    BigInteger big = new BigInteger(id, 36);
    System.out.println(big);

    /*      ClientServicesQA cs = new ClientServicesQA();
          WebDriver driver;
                  
          Calendar cal = Calendar.getInstance();
          int dayOfMonth = cal.get(Calendar.DAY_OF_MONTH);
          int month = cal.get(Calendar.MONTH);
          int year = cal.get(Calendar.YEAR);
                  
                  
                  
          driver = new FirefoxDriver();
          String baseURL  = "https://login-aws-qa.tegrity.com/Service/login.aspx";
    //      cs.loginToClientServices(baseURL, driver);
    //      cs.createNewTegrityCustomer(driver);
          cs.createNewInstitution(driver, dayOfMonth, month, year);
                  
    //      System.out.println("The current day of the month is: " + dayOfMonth);
    //      System.out.println("The current month is: " + month);
    */

}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    Class cls = java.util.Map.Entry.class;
    String name = cls.getName();
    if (name.lastIndexOf('.') > 0) {
        name = name.substring(name.lastIndexOf('.') + 1); // Map$Entry
        name = name.replace('$', '.'); // Map.Entry
    }//w  w w. ja  va2s  . co m
}