think in javaµÚÊ®ÎåÕ¹ØÓÚÍøÂç±à³ÌµÄ¶ÁÊé±Ê¼Ç
¶ÔÓÚjavaµÄÍøÂç±à³ÌÊéÖÐÌÖÂÛµÄÈ«²¿¹éÄÉÆðÀ´ÓÐSocketµÄʹÓã¬DatagramSocketµÄʹÓã¬javaÓëCGIµÄÅäºÏʹÓã¬javaÁ¬½ÓÊý¾Ý¿âÒÔ¼°javaÖе÷ÓÃÔ¶³Ì·½·¨¡£
Ê×ÏÈÊÇSocketµÄʹÓ㬶ÔÓÚ·þÎñ¶ËÀ´Ëµ£¬Ó¦¸ÃÉùÃ÷µÄÊÇServerSocket¶ÔÏó£¬È»ºóʹÓÃSocket
accept()·½·¨½øÐжԶ˿ڽøÐмàÌý¡£Èç¹ûÓпͻ§»ú´´½¨Ò»¸öSocket(·þÎñÆ÷IP,
·þÎñÆ÷¶Ë¿Ú)¶ÔÏó½øÐÐÁ¬½Ó£¨´´½¨Ò»¸öSocketµÄʱºò¾Í»á×Ô¶¯½øÐÐÁ¬½Ó£©¡£accept·½·¨¾Í»á·µ»ØÒ»¸öSocket¶ÔÏó¡£´Ëʱ·þÎñÆ÷Óë¿Í»§»ú¾ÍÄܾÍÄÜ
ͨ¹ýSocketÌṩµÄgetInputStream()ºÍgetOutputStream()·µ»ØµÄIO½øÐн»»¥ÁË¡£µ«ÊÇҪעÒâµÄ¾ÍÊÇÒ»µ©
ServerSocketµ÷ÓÃÁËaccept()Õâ¸ö·½·¨£¬ÄÇôÕâ¸öÏ߳̾ͻáÓÃÓÚ¼àÌý¶Ë¿Ú£¬Èç¹ûûÓпͻ§¶ËÁ¬½Ó½øÀ´Õâ¸öÏ߳̾ͻáһֱͣÁôÔÚÄǸö·½·¨Àï¡£Ëù
ÒÔSocket×îºÃ»¹ÊǺͶàÏ߳̽øÐнáºÏʹÓᣱÈÈçдһ¸ö¼Ì³ÐÁËThreadµÄÀàÀïÃæ°üº¬Ò»¸öSocket¶ÔÏó¡£
Ö®ºóÊÇDatagramSocketµÄʹÓã¬Õâ¸öºÍSocketµÄ²»Í¬ÔÚÓÚ£ºDatagramSocketÊÇUDPÐÒé¶øSocketÊÇTCP/IPÐ
Òé¡£UDPÐÒéµÄ¿É¿¿ÐÔ±ÈTCP/IPÐÒéÂԲµ«ÊÇUDPÐÒéÈ´ÓкܸߵĴ«ÊäËٶȣ¬Ê¹ÓÃÓÃÓÚ¼´Ê±ÐÔºÜÇ¿µÄ³ÌÐò£¨Ä§ÊÞÕù°ÔÓë°µºÚ¶¼Êǽ¨Á¢UDPÁ¬½ÓµÄ£©¡£
¶ÔÓÚDatagramSocketµÄʹÓ÷½·¨ºÍSocketµÄÓкܴó²»Í¬¡£¾ßÌåÀ´ËµDatagramSocketÒªºÜDatagramPacketÀàÅäºÏ
ʹÓã¬DatagramSocket²»±ØÏñSocketÄÇÑù½¨Á¢Ò»¸öÒ»Ò»¶ÔÓ¦µÄÁ¬½Ó£¬DatagramSocketÔÚ½»»¥Éϳ£ÓõÄÁ½¸ö·½·¨ÊÇvoid
receive(DatagramPacket p)ºÍvoid send(DatagramPacket
p)¡£¶ÔÓÚDatagramSocket¶ÔÏñµÄ´´½¨·½·¨ÓжàÖÖ£¬ÆäÖÐnew DatagramSocket(int
port)Êǽ«Æä°ó¶¨µ½±¾µØÖ÷»úÉϵÄÖ¸¶¨¶Ë¿Ú£¬¶ønew
DatagramSocket()ÔòÊǽ«Æä°ó¶¨µ½±¾µØÖ÷»úÉÏÈκοÉÓõĶ˿ڡ£È»ºóÖ»ÐèʹÓÃreceiveºÍsendÊÕ·¢DatagramPacket¶Ô
Ïó¡£DatagramPacketÖаüº¬Á˱¾µØµØÖ·¡¢¶Ë¿Ú¡¢ÏûÏ¢ÒÔ¼°Ä¿µÄµØµÄµØÖ·ºÍ¶Ë¿Ú¡£ËùÒÔÊÕµ½Ò»¸öDatagramPacket°üÒÔºó£¬Ö»Ðëµ÷Ó÷½·¨
getAddress(),getPort()¾ÍÄÜ»ñµÃ·¢ËÍ»úÆ÷µÄÐÅÏ¢£¬ÓÐÁËÕâЩÐÅÏ¢¾ÍÄܶԷ¢ËÍÕß½øÐз´À¡¡£
¾ßÌå¿ÉÒԲο´ÊéÖиø³öµÄʹÓÃʾÀý£º
//: Dgram.java
// A utility class to convert back and forth
// Between Strings and DataGramPackets.
import java.net.*;
public class Dgram {
public static DatagramPacket toDatagram(String s, InetAddress destIA, int dest
Ïà¹ØÎĵµ£º
1. RabbitÁ÷ÃÜÂ루Rabbit Stream Cipher£©¼ò½é
RabbitÁ÷ÃÜÂëÊÇÓÉCryptico¹«Ë¾£¨http://www.cryptico.com£©Éè¼ÆµÄ£¬ÃÜÔ¿³¤¶È128룬
×î´ó¼ÓÃÜÏûÏ¢³¤¶ÈΪ264 Bytes£¬¼´16 TB£¬ÈôÏûÏ¢³¬¹ý¸Ã³¤¶È£¬ÔòÐèÒª¸ü»»ÃÜÔ¿¶ÔʣϵÄÏûÏ¢½øÐд¦Àí¡£ËüÊÇÄ¿Ç°°²È«ÐԽϸߣ¬¼Ó/½âÃÜËٶȱȽϸßЧµÄÁ÷ÃÜÂëÖ®Ò»£ ......
1.[http://www.javaalmanac.com] – Java¿ª·¢ÕßÄê¼øÒ»ÊéµÄÔÚÏß°æ±¾. ÒªÏë¿ìËٲ鵽ijÖÖJava¼¼ÇɵÄÓ÷¨¼°Ê¾Àý´úÂë, ÕâÊÇÒ»¸ö²»´íµÄÈ¥´¦.
2.[http://www.onjava.com] – O’ReillyµÄJavaÍøÕ¾. ÿÖܶ¼ÓÐÐÂÎÄÕÂ.
3.[http://java.sun.com] – ¹Ù·½µÄJava¿ª·¢ÕßÍøÕ¾ – ÿÖܶ¼ÓÐÐÂÎÄÕ·¢±í.
4.[http:/ ......
Java SwingÖеÄJTreeÄ£ÐÍ
2009-01-04 10:40
±¾ÎĽéÉÜJava SwingÖеÄJTreeÄ£ÐÍ£¬½éÉÜÈçºÎ´´½¨¡¢Ð޸ġ¢±éÀú£¬ÉèÖÃÊ÷¡£²Î¿¼Core Java2Ïà¹ØÕ½ڼ°ÆäÔ´´úÂë¡£
SwingÊ÷ʹÓÃÈËÃÇËùÊìϤµÄÎļþ¼ÐºÍÊ÷ҶͼÀ´ÏÔʾ·Ö²ãµÄÊý¾Ý¡£Ê÷Óɽڵã×é³É£¬½Úµã¿ÉÒÔÊÇÎļþ¼Ð£¬Ò²¿ÉÒÔÊÇÊ÷Ò¶¡£Îļþ¼Ð¿ÉÒÔÓÐ×ӽڵ㣬³ý¸ù½ÚµãÖ®ÍâµÄËùÓнڵ㶼ֻÓÐÒ»¸ö¸ ......
¹éÄÉһЩÍøÉÏÈ¡JAVA·¾¶µÄ·½·¨£º
×¢Ã÷£ºÈç¹û´ÓANTÆô¶¯³ÌÐò£¬this.getClass().getResource("")È¡³öÀ´µÄ±È½Ï¹Ö£¬Ö±½ÓÓÃJAVAÃüÁîÐе÷ÊԾͿɳɹ¦¡£
µÃµ½classpathºÍµ±Ç°ÀàµÄ¾ø¶Ô·¾¶µÄһЩ·½·¨
»ñµÃCLASSPATHÖ®Íâ·¾¶µÄ·½·¨£º
URL base = this.getClass£¨£©.getResource£¨""£©£» //ÏÈ»ñµÃ±¾ÀàµÄËùÔÚλÖã¬Èç/home/popeye/ ......
¹ÖÒìÖ®Ò»£º
connect(SocketAddress endpoint):Õâ¸ö·½·¨£¬³¢ÊÔÁ¬½Óserver¶Ë£¬Èç¹ûÁ¬½Ó²»ÉÏ£¬¾ÍÅ׳öIOExceptionÒì³£¡£Èç¹ûÁ¬½Ó³É¹¦ÁË£¬¾Í¼ÌÐøÖ´ÐÐÏÂÒ»²½µÄ´úÂë¡£
¹ÖÒìÖ®¶þ£º
boolean isConnected() :Õâ¸ö·½·¨µÄ½á¹û½ö½ö´ú±íÕâ¸ösocketÔø¾³É¹¦Á¬½Óµ½ÁËserver£¬µ«²¢²»±íʾÏÖÔÚÕâ¸öʱ¿ÌËüºÍserverÈÔ±£³ÖÁ¬½Ó״̬¡£
ÓÐ ......