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
Ïà¹ØÎĵµ£º
µÚ8Õ ¶àÏß³Ì
(Ò»)¿Î³ÌÄÚÈÝ
8.1Ï̵߳Ļù±¾¸ÅÄî
8.1.1Ï̵߳ÄÉúÃüÖÜÆÚ
8.1.2Ï̵߳÷¶ÈÓëÓÅÏȼ¶
8.2 ThreadÀàºÍRunnable½Ó13
8.2.1 ThreadÀà
8.2.2 Runnable½Ó¿Ú
8.3Ï̻߳¥³âºÍͬ²½
8.3.1Ï̻߳¥³â
8.3.2Ïß³Ìͬ²½
(¶þ)ѧϰĿµÄÓëÒªÇó
±¾Õ½éÉܶàÏ̵߳ĸÅÄîºÍ±àд¶àÏ̳߳ÌÐòµÄ·½·¨£¬ÊµÏÖÏß³ÌÖ®¼äÏ໥ͨÐźÍͬ²½µÄ¼¼ ......
´úÂëÈçÏ£º
1 String command = " cmd /c C:/Program Files/MySQL/MySQL Server 5.0/bin>mysqldump -h localhost -u root -p aijia > E:/aijia.dmp " ;
2 try {
3 Process process& ......
×î½üÓöµ½Ò»¸öÐèÇóÒªÔÚlinuxÏÂÓÃjava µ÷ÓÃmysql¿Í»§¶ËÔ¶³ÌµÇ½mysql·þÎñÆ÷£¬´Ó¿Í»§¶Ë»úÆ÷µ¼Èëmysql½Å±¾£¬´Ómysql·þÎñÆ÷¶Ëµ¼³ö±íÖеÄÊý¾Ý¡£ÒÔÏÂÊÇÓõ½µÄÖ÷Òª·½·¨£º
Java ´úÂë
/**
* µ¼ÈëÊý¾Ý
* @param ½Å±¾µÄµØÖ·ºÍÃû³Æ
* @return ÊÇ·ñ³ ......
¾ÙÀý×Ó˵Ã÷Ò»ÇС£
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 ......
Ŀ¼
1. ¼ò½é
2. °²×°
3. log4j»ù±¾¸ÅÄî
3.1. Logger
3.2. Appender
3.2.1. ʹÓÃConsoleAppender
3.2.2. ʹÓÃFileAppender
3.2.3. ʹÓÃWriterAppender
3.3. Layout
3.4. »ù±¾Ê¾Àý
3.4.1. SimpleLayoutºÍFileAppender
3.4.2. HTMLLayoutºÍWriterAppender
3.4.3. PatternLayoutºÍConsoleAppender
4. ʹÓÃÍⲿ ......