Monday, 8 April 2013

Basic Java String Operations(How to remove,include double quotes..etc)

public class Checkstring {
    public static void main(String[] args) {
         
        StringBuffer buffer = new StringBuffer();
       
        String name = "Name";
        String namevalue = "xxx";
       
        buffer.append("<string name = "  +"\""+name+"\""  +">"+namevalue.trim()+"</string>");
        System.out.println("here output is "+buffer.toString());
       
       
        String s = "test" + "/" + "test2";
       
        String sampledoublequote =  "Luni";
       
        System.out.println("test here "+sampledoublequote.replaceAll("^\"|\"$", ""));
       
       
        String s1 =  "\"" +"out"+  "\"";
        System.out.println(s);
        System.out.println("double quotes "+s1);
        String testcolon = "namratha;namratha";
        System.out.println("Test colon "+testcolon.replace(";", ""));
       
       
       
       
//        String addQuotes(String in ) {
//            return "\"" + in + "\"";
//            }

    }

}

No comments:

Post a Comment

Pass a HashMap from Angular Client to Spring boot API

This example is for the case where fileData is very huge and in json format   let map = new Map<string, string>()      map.set(this.ge...