Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

java socket±à³Ì

Ç°Ò»¶Îʱ¼ä¸Õ×öÁ˸öjava³ÌÐòºÍÍøÂçÉ϶ą̀»úÆ÷µÄc³ÌÐòͨѶµÄÏîÄ¿£¬×ñÑ­µÄÊÇTCP/IPЭÒ飬Óõ½ÁËjavaµÄSocket±à³Ì¡£ÍøÂçͨѶÊÇjavaµÄÇ¿ÏÓÃTCP/IPЭÒé¿ÉÒÔ·½±ãµÄºÍÍøÂçÉϵÄÆäËû³ÌÐò»¥Í¨ÏûÏ¢¡£
ÏÈÀ´½éÉÜÏÂÍøÂçЭÒ飺
    TCP/IP
        Transmission Control Protocol ´«Êä¿ØÖÆЭÒé
        Internet Protocol »¥ÁªÍøЭÒé
    UDP
        User Datagram Protocol Óû§Êý¾ÝЭÒé
Á¬½ÓЭÒ飺
    ·ÖΪ£º
    ÃæÏòÁ¬½ÓЭÒé: Connection Oriented Protocol
    ·ÇÁ¬½ÓЭÒé: Connectionless Protocol
    1).ÃæÏòÁ¬½ÓЭÒéÊÇÖ¸Á½Ì¨µçÄÔÔÚ´«ÊäÊý¾ÝÇ°£¬ÏȻὨÁ¢Ò»¸öרÊôµÄÁ¬½Ó¡£¾ÍÈçµçОֵĽ»»»»ú»áΪ´òµç»°Ë«·½ÌṩרÊôÁ¬½ÓÒ»Ñù¡£
    InternetÉϵÄÃæÏòÁ¬½ÓЭÒé¾ÍÊÇTCP/IP
    Ìص㣺ȷÈÏ»ØÓ¦£»·Ö×éÐòºÅ£»Á÷Á¿¿ØÖÆ¡£
    TCP/IPÊôÓÚ¿É¿¿ÐÔ´«Ê䣬Êʺϲ»ÈÝÐíÓд«Êä´íÎóµÄÍøÂç³ÌÐòÉè¼ÆʹÓÃ
    2).·ÇÁ¬½ÓЭÒ飺ÎÞרÊôÁ¬½Ó£¬ÎÞ·Ö×飬ÈÝ´í£¬¾àÀë¶Ì£¬¿Éͬʱ¶Ô¶ą̀µçÄÔ½øÐÐÊý¾Ý´«Êä
    InternetÉϵķÇÁ¬½ÓЭÒé¾ÍÊÇUDP
    TCPÔÚÍøÂçͨÐÅÉÏÓм«Ç¿µÄÉúÃüÁ¦£¬ÀýÈçÔ¶³ÌÁ¬½Ó£¨Telnet£©ºÍÎļþ´«Ê䣨FTP£©¶¼ÐèÒª²»¶¨³¤¶ÈµÄÊý¾Ý±»¿É¿¿µØ´«Êä¡£Ïà±ÈÖ®ÏÂUDP²Ù×÷¼òµ¥£¬¶øÇÒ½öÐèÒª½ÏÉٵļ໤£¬Òò´Ëͨ³£ÓÃÓÚ¾ÖÓòÍø¸ß¿É¿¿ÐԵķÖɢϵͳÖÐclient/serverÓ¦ÓóÌÐò¡£
Socket ÊdzÌÐòÓëÍøÂç¼äµÄÒ»ÖÖ½Ó¿Ú£¬´ó²¿·ÖÍøÂçÓ¦ÓóÌÐò¶¼Êǵã¶ÔµãµÄ£¬Ëùνµã¾ÍÊÇ·þÎñÆ÷¶ËºÍ¿Í»§¶ËËùÖ´ÐеijÌÐò¡£SocketÊÇÓÃÀ´½ÓÊպʹ«ËÍ·Ö×éµÄÒ»¸ö¶Ëµã¡£
javaµÄSocket±à³ÌÒªÓõ½java.net°ü£¬×î³£ÓõÄÊÇnet°üϵÄ6¸öÀࣺInetAddress(»¥ÁªÍøЭÒé (IP) µØÖ·)À࣬Socket(Ì×½Ó×Ö)À࣬ServerSocket(Ì×½Ó×Ö·þÎñÆ÷)À࣬DatagramSocket(·¢ËͺͽÓÊÕÊý¾Ý±¨°üµÄÌ×½Ó×Ö)À࣬DatagramPacket(Êý¾Ý±¨°ü)À࣬MulticastSocket(¶à²¥Êý¾Ý±¨Ì×½Ó×ÖÀàÓÃÓÚ·¢ËͺͽÓÊÕ IP ¶à²¥°ü)À࣬ÆäÖÐInetAddress¡¢Socket¡¢ServerSocketÀàÊÇÊôÓÚTCPÃæÏòÁ¬½ÓЭÒ飬DatagramSocket¡¢DatagramPacketºÍMulticastSocketÀàÔòÊôÓÚUDP·ÇÁ¬½ÓЭÒéµÄ´«ËÍÀà¡£
±¾ÏîÄ¿ÒòΪʹÓÃTCP/IPЭÒ飬Ö÷ÒªÓõ½SocketºÍServerSocketÀ


Ïà¹ØÎĵµ£º

ÓÃJAVAʵÏÖ¶àỊ̈߳¨Éú²úÕßÓëÏû·ÑÕßÎÊÌ⣩


public class MultiThread {
 public static void main(String[] args) {
  ProductStack box = new ProductStack("box");
  Producer p1 = new Producer(box, "p1");
  Producer p2 = new Producer(box, "p2");
  Producer p3 = new Producer(box, "p3");
 &nb ......

Javaѧϰ±Ê¼Ç£¨1£© ¶ÔÏó³õʼ»¯Ë³Ðò

ÔÚJavaÖУ¬µ±Ò»¸ö¶ÔÏó±»´´½¨Ê±£¬³ÉÔ±±äÁ¿µÄ³õʼ»¯¼°¹¹Ôì·½·¨µÄµ÷ÓÃ×ñÑ­ÒÔÏÂ˳Ðò£º
1. ½«·ÖÅä¸ø¶ÔÏóµÄ´æ´¢¿Õ¼ä³õʼ»¯³É¶þ½øÖƵÄÁã¡£
2. µ÷ÓÃËùÓлùÀàµÄ¹¹Ôì·½·¨¡£Õâ¸ö²½Öè»á²»¶ÏµØ·´¸´µÝ¹éÏÂÈ¥£¬Ê×ÏÈÊǹ¹ÔìÕâÖÖ²ã´Î½á¹¹µÄ¸ù£¬È»ºóÊÇÏÂÒ»²ã×ÓÀ࣬µÈµÈ£¬Ö±µ½×îµ×²ãµÄ×ÓÀà¡£
3. °´ÕÕÉùÃ÷µÄ˳Ðòµ÷ÓóÉÔ±µÄ³õʼ»¯·½·¨¡£
4. µ÷ ......

java ÈÕÆÚ¸ñʽ»¯

1 SimpleDateFormatµ£µ±ÖØÈÎ,ÔõÑù¸ñʽ»¯¶¼ÐÐ
import java.util.Date;
import java.text.SimpleDateFormat;
public class Demo
{
public static void main(String[] args)
{
Date now=new Date();
SimpleDateFormat f=newSimpleDateFormat("½ñÌìÊÇ"+"yyyyÄêMMÔÂddÈÕ E kkµãmm·Ö");
System.out.println(f.fo ......

java¼¯ºÏ¿ò¼Ü


 
 
JavaΪÊý¾Ý½á¹¹µÄÓ³É䶨ÒåÁËÒ»¸ö½Ó¿Újava.util.Map.ËüÓÐËĸöʵÏÖÀ࣬·Ö±ðÊÇHashMap, Hashtable,LinkedHashMapºÍTreeMapÖ÷ÒªÓÃÓÚ´æ´¢¼üÖµ¶Ô£¬¸ù¾Ý¼üµÃµ½Öµ£¬Òò´Ë²»ÔÊÐí¼üÖظ´£¬µ«ÔÊÐíÖµÖظ´¡£
HashMapÊÇÒ»¸ö×î³£ÓõÄMap£¬Ëü¸ù¾Ý¼üµÄHashCodeÖµ´æ´¢Êý¾Ý£¬¸ù¾Ý¼ü¿ÉÒÔÖ±½Ó»ñÈ¡ËüµÄÖµ£¬¾ßÓкܿìµÄ·ÃÎÊËٶȣ¬± ......

[Java] doubleÓëStringÖ®¼äµÄÏ໥ת»»·½·¨

8ÖÖ»ù±¾Êý¾ÝÀàÐÍÓÐÏàÓ¦µÄ8ÖÖ°ü×°Àà(Wrapper)¶ÔÓ¦,·Ö±ðÊÇ:Character,Byte,Short,Integer,Long,Float,Double,Boolean.
Ìصã:
1.ÌṩÁËvalueOf(String)ÓÃÓÚ´Ó×Ö·û´®×ª»»¼°toString()ת»»³É×Ö·û´®
2.ͨ¹ýxxxxValue()·½·¨¿ÉÒԵõ½Ëù°ü×°µÄÖµ,ÈçInteger¶ÔÏóµÄintValue()·½·¨.
ʾÀý´úÂë:
public class DoubleAndString {
pu ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ