第 11 章  java 网络的基本知识

Click here to load reader

Upload: raymond-stephens

Post on 03-Jan-2016

41 views

Category:

Documents


6 download

DESCRIPTION

第 11 章  Java 网络的基本知识. 11.1 使用 URL 11.2 读取 URL 中的资源 11.3 显示 URL 资源中的 html 文件 11.4 处理超链接 11.5 InetAdress 类 11.6 套接字 11.7   网络中的数据压缩与传输 11.8 UDP 数 据 报 11.9 广播数据报. 11.1 使用 URL. - PowerPoint PPT Presentation

TRANSCRIPT

  • 11Java

    11.1URL11.2URL11.3URLhtml11.411.5InetAdress11.611.7 11.8UDP 11.9

  • 11.1 URL

    URLUniform Resource LocatorURLURLURLURLURL URL .

  • URLpublic URL(String spec) throws MalformedURLExceptiontry { url=new URL("http://www.tup.tsinghua.edu.cn"); }catch(MalformedURLException e) { System.out.println ("Bad URL:"+url); }

  • 11.2 URL

    URLInputStream openStream() URL

  • 11.3 URLhtml

    Javax.swingJEditorPanehtmlhtmlJEditorPanehtmlJEditorPane

  • 11.4

    JEditorPanesetEditablefalseJEditorPaneHyperlinkEventHyperlinkEventURL

  • 11.5 InetAdress

    java.netInetAddressInternetIP www.sina.com.cn/202.108.35.210DNSIP

  • 11.6

    IPInternet IP

  • try{ Socket mysocket=newSocket(http://192.168.0.78,1880); }catch(IOException e){}

  • mysocket mysocketgetInputStream() mysocketgetOutputStream()

  • ServerSocketServerSocketServerSocket(int port)portportServerSocketserver_socketaccept()accept()SocketSocketSocketscgetOutputStream()SocketmysocketgetInputStream()SocketscgetInputStream()SocketmysocketgetOutputStream()

  • 11.7 ZipOutputStreamZipOutputStreamZipOutputStreamoutZipOutputStreamZipOutputStreampublic ZipOutputStream(OutputStream out)

  • 11.8 UDP

    UDPTCPUDP UDP 1 2

  • 1 DatagramPacket DatagramPacket(byte data[], int length, InetAddtress address,int port)dataaddressport DatagramSocketDatagramSocket()

  • 2 DatagramSocketDatagramSocket(int port) DatagramSocketreceive(DatagramPacket pack) .

  • 11.9

    Interneta.b.c.da128b.c.dAa128192a.bc.dBa192a.b.cdC224.0.0.0~224.255.255.255DDDDABCD