Showing posts with label String and Xml manipulation. Show all posts
Showing posts with label String and Xml manipulation. Show all posts

Saturday, September 27, 2014

Sample

public class StringBuilderTest {
    StringBuilder StringBuilderShow() {
        StringBuilder dialogStr = new StringBuilder();
        StringBuilderTest talClazz = new StringBuilderTest();
        dialogStr.append((new StringBuilder("Table: ")).append(talClazz.getClass().getName()).append("\n"));
        return dialogStr;
    }

    public static void main(String args[]) {
        StringBuilderTest test = new StringBuilderTest();
   StringBuilder str=test.StringBuilderShow();
   str.append("\r\n\t abishkar");
        System.out.println(str);
    }

}


public class StringImp {
    public static void main(String[] args){
       
    String d=new StringBuilder(String.valueOf("abc")).append(":").append("def").append(":").append("ijk").toString();
    System.out.println(d);

}
}

Xml manipulation

package StringManipulation;

import java.io.IOException;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;


public class Format {
    public static void main(String[] args) {
        String.format("Executing Statement: %s .", "this is test");
       
       new String("testApple").indexOf("ppl");
   
       DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
       DocumentBuilder db=null;
    try {
        db = dbf.newDocumentBuilder();
    } catch (ParserConfigurationException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
   
           ClassLoader cl = Format.class.getClassLoader();
        java.io.InputStream xmlFile = cl.getResourceAsStream("dbInformation/info.xml");
        Document dom=null;
        try {
            dom = db.parse(xmlFile);
        } catch (SAXException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        Element docEle = dom.getDocumentElement();
        try {
            dom = db.parse(xmlFile);
        } catch (SAXException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
       
 


}
}