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

javaÓëÍøÂç


1 ÍøÂçͨÐŵı¾ÖÊÊǽø³Ì¼äͨÐÅ¡£   
2 TcpЭÒéºÍUDPЭÒé
TCP£º¿ªÏú´ó£¬ÓÃÓÚ¿É¿¿ÐÔÒªÇó¸ßµÄ³¡ºÏ¡£
TCPµÄ¹ý³ÌÏ൱ÓÚ´òµç»°µÄ¹ý³Ì
UDP£ºÓÃÔÚ¶ÔʵʱÐÔÒªÇó±È½Ï¸ßµÄ³¡ºÏ¡£
UDPµÄ¹ý³ÌÏ൱ÓÚдÐŵĹý³Ì¡£
×¢Ò⣺socketÊÇÌ×½Ó×Ö£¬ipºÍport£¨¶Ë¿ÚºÅ 0~65535¸ö¶Ë¿Ú£¬Ò»¸ö¶Ë¿ÚÖ»ÄÜÓÐÒ»¸ö½ø³Ì£©
3£¬    TCPͨÐÅ»úÖÆ£¬tcpÊÇÃæÏòÁ¬½ÓµÄ£¬ÊµÏÖ¶àÏ̵߳ķ½·¨ÓÐÈý¸ö
¢Ù Ϊÿ¸ö¿Í»§·ÖÅäÒ»¸ö¹¤×÷Ï̡߳£
¢Ú  ´´½¨Ò»¸öÏ̳߳أ¬ÓÉÆäÖеŤ×÷Ïß³ÌÀ´Îª¿Í»§·þÎñ¡£
¢Û  ÀûÓÃJDKµÄJavaÀà¿âÖÐÏֳɵÄÏ̳߳أ¬ÓÉËüµÄ¹¤×÷Ïß³ÌÀ´Îª¿Í»§·þÎñ¡£
ÏÂÃæÒÔΪÿ¸ö¿Í»§·ÖÅäÒ»¸ö¹¤×÷Ïß³ÌÀ´ÊµÏÖ¶àÏß³Ì
ÔÚ·þÎñ¶Ë
import java.net.*;
import java.io.*;
public class TCPServer2 {
   public static void main(String[] args) throws Exception{
      ServerSocket ss=new ServerSocket(9000);//¶Ë¿ÚºÅ
      while(true){
           Socket s=ss.accept();//Á¬½Ó¼àÌý¿Í»§¶Ë
           System.out.println(s.getInetAddress());
           Thread t=new ServerThread(s);//ʵÏÖ¶àÏß³ÌÁ¬½Ó
           t.start();
      }
   }
}
class ServerThread extends Thread{//·ÖÅäÏß³Ì
   Socket s;
   public ServerThread(Socket s){
      this.s=s;
   }
public void run(){
   try {
      OutputStream os=s.getOutputStream();//ÔÚÍøÂçÖлñÈ¡Êä³öÁ÷
      PrintWriter out=new PrintWriter(os);
      for(int i=1;i<=30;i++){
      out.println("Hello "+i);//ͨ¹ýÍøÂç·¢ÏûÏ¢¸ø¿Í»§¶Ë
      out.flush();
      Thread.sleep(1000);
           }
      } catch (Exception


Ïà¹ØÎĵµ£º

¡¶javaÓïÑÔ³ÌÐòÉè¼Æ£¨Ò»£©¡·2009Äê×Ôѧ¿¼ÊÔ´ó¸ÙµÚ9ÕÂ

µÚ9Õ ÊäÈëºÍÊä³öÁ÷
(Ò»)¿Î³ÌÄÚÈÝ
9.1×Ö½ÚÁ÷ºÍ×Ö·ûÁ÷
9.1.1 File¶ÔÏó
9.1.2Á÷¶ÔÏó
9.2»º³åʽÊäÈëÊä³ö
9.2.1»º³åʽÊäÈë
9.2.2»º³åʽÊä³ö
9.3Ëæ»ú·ÃÎÊ
9.4Îļþ¶Ô»°¿ò
(¶þ)ѧϰĿµÄÓëÒªÇó
±¾Õ½éÉÜJava³ÌÐòÊý¾ÝÎļþµÄÊäÈëÊä³ö¼¼Êõ¡£ÒªÇóÄܱàд¼òµ¥µÄJavaÎļþ´¦Àí³ÌÐò¡£
(Èý)¿¼ºË֪ʶµãÓ뿼ºËÒªÇó
1.´´½¨File¶ÔÏó£ ......

java µ÷ÓÃmysql¿Í»§¶Ëµ¼È룬µ¼³öÊý¾Ý

 ×î½üÓöµ½Ò»¸öÐèÇóÒªÔÚlinuxÏÂÓÃjava µ÷ÓÃmysql¿Í»§¶ËÔ¶³ÌµÇ½mysql·þÎñÆ÷£¬´Ó¿Í»§¶Ë»úÆ÷µ¼Èëmysql½Å±¾£¬´Ómysql·þÎñÆ÷¶Ëµ¼³ö±íÖеÄÊý¾Ý¡£ÒÔÏÂÊÇÓõ½µÄÖ÷Òª·½·¨£º
Java ´úÂë 
/**  
 * µ¼ÈëÊý¾Ý  
  * @param  ½Å±¾µÄµØÖ·ºÍÃû³Æ  
 * @return ÊÇ·ñ³ ......

JAVA»·¾³±äÁ¿ÉèÖÃ

¾ÙÀý×Ó˵Ã÷Ò»ÇС£
JAVA_HOME£º C:\j2sdk1.4.2_13
 
Path£º         C:\j2sdk1.4.2_13\bin;
Classpath£º.;JAVA_HOME\lib\tools.jar ; JAVA_HOME\lib\dt.jar;
                 &n ......

javaʱ¼ä¶¯Ì¬ÏÔʾ Á½ÖÖ·½·¨

ʱ¼ä¶¯Ì¬ÏÔʾ
1.·½·¨Ò» ÓÃTimerTask
ÀûÓÃjava.util.TimerºÍjava.util.TimerTaskÀ´×ö¶¯Ì¬¸üУ¬±Ï¾¹Ã¿´Î¸üпÉÒÔ¿´×÷ÊǼÆʱ1Ãë·¢ÉúÒ»´Î¡£
´úÂëÈçÏ£º
import java.awt.Dimension;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Timer;
import java.util ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ