本文共 2401 字,大约阅读时间需要 8 分钟。
package com.animals;import org.jsoup.Jsoup;import org.jsoup.nodes.Document;import org.jsoup.nodes.Element;import org.jsoup.select.Elements;public class TestXml { private static String getType(Object a) { return a.getClass().toString(); } public static void main(String[] args) throws Exception { String html = "Hello HTML
"; Document doc = Jsoup.parse(html); System.out.println("type="+getType(doc)); Elements as= doc.getElementsByTag("p"); for (Element e : as) { System.out.println(e.text()); } }}
package com.animals;import java.io.FileOutputStream;public class TestXml { private static String getType(Object a) { return a.getClass().toString(); } public void WriteStringToFile5(String filePath) { try { FileOutputStream fos = new FileOutputStream(filePath); String s = "html"; fos.write(s.getBytes()); fos.close(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } public static void main(String[] args) throws Exception { String filePath = "E:\\link.html"; new TestXml().WriteStringToFile5(filePath); }}
传递的参数是整型数据a
调用start方法之前通过线程类的构造方法将数据传入线程。
package com.thread;public class MyThread1 extends Thread{ private String name; private int a; public MyThread1(String name,int a) { this.name = name; this.a = a; } public void run() { System.out.println("hello " + name); int b = a+5; System.out.println("result=" + b); } public static void main(String[] args) { Thread thread = new MyThread1("world",9); thread.start(); }}
package com.thread;public class MyThread2 implements Runnable{ private String name; public void setName(String name) { this.name = name; } public void run() { System.out.println("hello " + name); } public static void main(String[] args) { MyThread2 myThread = new MyThread2(); myThread.setName("world"); Thread thread = new Thread(myThread); thread.start(); }}
转载地址:http://thqen.baihongyu.com/