10. สิ่งผิดปกติ

The Camtasia Studio video content presented here requires JavaScript to be enabled and the latest version of the Macromedia Flash Player. If you are you using a browser with JavaScript disabled please enable it now. Otherwise, please update your version of the free Flash Player by downloading here.

 
รหัสที่ 10-12  คลาส WebPage มีเมท็อดคืน Scanner ให้อ่านเว็บเพจ
import java.io.*;
import java.net.*;
import java.util.Scanner;

public class WebPage {
  private Scanner scanner;
  public WebPage(String page) throws WebPageException {
    try {
      URLConnection urlc = new URL(page).openConnection();
      scanner = new Scanner(urlc.getInputStream());
    } catch (IOException e) {
      throw new WebPageException(e.getMessage());
    }
  }
  public Scanner getScanner() {
    return scanner;
  }
}
©2009 S.Prasitjutrakul