Example usage for java.lang String toString

List of usage examples for java.lang String toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

This object (which is already a string!) is itself returned.

Usage

From source file:Main.java

public static void main(String[] args) {
    String s = "java2s.com";
    System.out.println(s.toString());
}

From source file:Main.java

public static void main(String[] args) {
    File outputFile = new File("test.txt");

    try (FileChannel fileChannel = new FileOutputStream(outputFile).getChannel()) {
        String text = getText();
        byte[] byteData = text.toString().getBytes("UTF-8");
        ByteBuffer buffer = ByteBuffer.wrap(byteData);
        fileChannel.write(buffer);//from  w w w.j ava  2s .c o  m
    } catch (IOException e1) {
        e1.printStackTrace();
    }
}

From source file:Main.java

public static void main(String[] args) {

    String str = "Thu Jun 06 2013 00:00:00 GMT+0530";
    DateFormat outputDate = new SimpleDateFormat("EEE MMM dd yyyy hh:mm:ss");
    try {/*ww  w  . j ava 2  s. com*/
        Date date = outputDate.parse(str);
        String date1 = new SimpleDateFormat("dd-mm-yyyy, hh:mm:ss").format(date);
        System.out.println(date1.toString());
    } catch (ParseException e) {
        e.printStackTrace();
    }
}

From source file:org.vuphone.vandyupon.test.EventMetaRequestTester.java

public static void main(String[] args) {
    HttpClient c = new DefaultHttpClient();
    HttpPost post = new HttpPost("http://localhost:8080/vandyupon/events/");
    post.addHeader("Content-Type", "application/x-www-form-urlencoded");

    String params = "type=eventmetarequest&id=2&resp=xml";
    post.setEntity(new ByteArrayEntity(params.toString().getBytes()));

    try {/* www.  ja v a 2 s. c  o  m*/
        HttpResponse resp = c.execute(post);
        resp.getEntity().writeTo(System.out);
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    String source = "<p xmlns='http://www.java2s.com/nfe' versao='2.00'></p>";

    XPathFactory xPathFactory = XPathFactory.newInstance();
    XPath xPath = xPathFactory.newXPath();

    NamespaceContext context = new NamespaceContext() {
        String PREFIX = "nfe";
        String URI = "http://www.java2s.com/nfe";

        @Override/*  w  ww. java2  s  . c o  m*/
        public String getNamespaceURI(String prefix) {
            return (PREFIX.equals(prefix)) ? URI : XMLConstants.NULL_NS_URI;
        }

        @Override
        public String getPrefix(String namespaceUri) {
            return (URI.equals(namespaceUri)) ? PREFIX : XMLConstants.DEFAULT_NS_PREFIX;
        }

        @Override
        public Iterator getPrefixes(String namespaceUri) {
            return Collections.singletonList(this.getPrefix(namespaceUri)).iterator();
        }
    };
    xPath.setNamespaceContext(context);
    InputSource inputSource = new InputSource(new StringReader(source));
    String versao = xPath.evaluate("//nfe:p/@versao", inputSource);
    System.out.println(versao.toString());
}

From source file:org.vuphone.vandyupon.test.EventPostTester.java

public static void main(String[] args) {
    HttpClient c = new DefaultHttpClient();
    HttpPost post = new HttpPost("http://localhost:8080/vandyupon/events/");
    post.addHeader("Content-Type", "application/x-www-form-urlencoded");

    String params = "type=eventratingrequest&id=1&comments=true&numcom=10";
    post.setEntity(new ByteArrayEntity(params.toString().getBytes()));

    try {/*from ww  w  .  ja v a  2 s.  c  o m*/
        HttpResponse resp = c.execute(post);
        resp.getEntity().writeTo(System.out);
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:org.vuphone.vandyupon.test.EventRatingPostTest.java

public static void main(String[] args) {
    HttpClient c = new DefaultHttpClient();
    HttpPost post = new HttpPost("http://localhost:8080/vandyupon/events/");
    post.addHeader("Content-Type", "application/x-www-form-urlencoded");

    String params = "type=eventratingpost&event=1&user=chris&comment=awesome&value=1&resp=xml";
    post.setEntity(new ByteArrayEntity(params.toString().getBytes()));

    try {/* w ww.j a v  a  2 s  .  c  o  m*/
        HttpResponse resp = c.execute(post);
        resp.getEntity().writeTo(System.out);
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:org.vuphone.vandyupon.test.EventRequestTester.java

public static void main(String[] args) {
    HttpClient c = new DefaultHttpClient();
    HttpPost post = new HttpPost("http://localhost:8080/vandyupon/events/");
    post.addHeader("Content-Type", "application/x-www-form-urlencoded");

    String params = "type=eventrequest&lat=36.1437&lon=-86.8046&dist=100&resp=xml&userid=chris";
    post.setEntity(new ByteArrayEntity(params.toString().getBytes()));

    try {/*from w w w .  j  a va2 s. c o  m*/
        HttpResponse resp = c.execute(post);
        resp.getEntity().writeTo(System.out);
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:GetMethod.java

public static void main(String[] args) {
    Method[] ms = String.class.getMethods();
    for (int i = 0; i < ms.length; i++) {
        // System.out.println(ms[i].getName());
    }//from  w  ww  . j  a  v  a2s.  co m
    Method[] ims = XMLReader.class.getMethods();
    for (int i = 0; i < ims.length; i++) {
        // System.out.println(ims[i].getName());
    }
    Method[] sms = Size.class.getMethods();
    for (int i = 0; i < sms.length; i++) {
        // System.out.println(sms[i].getName());
    }
    String pc = new String();
    try {
        Method setCpu = String.class.getMethod("toString", String.class);
        setCpu.invoke(pc, "Intel 3.0");
        System.out.println(pc.toString());
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:edu.usd.btl.ontology.ToolTree.java

public static void main(String[] args) throws Exception {
    try {/*w  w w.ja  v a 2s .c om*/
        //File ontoInput = new File(".\\ontology_files\\EDAM_1.3.owl");
        ObjectMapper mapper = new ObjectMapper();
        OntologyFileRead ontFileRead = new OntologyFileRead();
        ArrayList<edu.usd.btl.ontology.BioPortalElement> nodeList = ontFileRead
                .readFile(".\\ontology_files\\EDAM_1.3.owl");
        //write nodelist to JSON string
        ObjectWriter treeWriter = mapper.writer().withDefaultPrettyPrinter();
        String edamJSON = mapper.writeValueAsString(nodeList);

        JsonNode rootNode = mapper.readValue(edamJSON, JsonNode.class);
        System.out.println("IsNull" + rootNode.toString());

        OntSearch ontSearch = new OntSearch();
        System.out.println(nodeList.get(0).getURI());
        String result = ontSearch.searchElementByURI("http://edamontology.org/topic_2817");
        System.out.println("RESULT = " + result);

        String topicSearchResult = ontSearch.findAllTopics();
        System.out.println("Topics Result = " + topicSearchResult);

        File ontFile = new File(".\\ontology_files\\EDAM_1.3.owl");
        String searchFromFileResult = ontSearch.searchNodeFromFile("http://edamontology.org/topic_2817",
                ".\\ontology_files\\EDAM_1.3.owl");
        System.out.println("File Response = " + searchFromFileResult.toString());
    } catch (IOException e) {
        System.out.println(e.getMessage());
    }

    //Hashmap stuff
    //        OntologyFileRead ontFileRead = new OntologyFileRead();
    //        ArrayList<edu.usd.btl.ontology.BioPortalElement> nodeList = ontFileRead.readFile(".\\ontology_files\\EDAM_1.3.owl");
    //        
    //        HashMap hm = new HashMap();
    //        
    //        //find topics
    //        ArrayList<OntologyNode> ontoTopicList = new ArrayList();
    //        
    //        for(BioPortalElement node : nodeList){
    //            //System.out.println("****" + node.getURI());
    //            hm.put(node.getURI(), node.getName());
    //        }
    //        
    //        Set set = hm.entrySet();
    //        Iterator i = set.iterator();
    //        while(i.hasNext()){
    //            Map.Entry me = (Map.Entry)i.next();
    //            System.out.println(me.getKey() + ": " + me.getValue());
    //        }
    //        System.out.println("HashMap Size = " + hm.size());
}