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

java SocketµÄ¹ÖÒìÖ®´¦

¹ÖÒìÖ®Ò»£º
connect(SocketAddress endpoint):Õâ¸ö·½·¨£¬³¢ÊÔÁ¬½Óserver¶Ë£¬Èç¹ûÁ¬½Ó²»ÉÏ£¬¾ÍÅ׳öIOExceptionÒì³£¡£Èç¹ûÁ¬½Ó³É¹¦ÁË£¬¾Í¼ÌÐøÖ´ÐÐÏÂÒ»²½µÄ´úÂë¡£
¹ÖÒìÖ®¶þ£º
boolean isConnected()  :Õâ¸ö·½·¨µÄ½á¹û½ö½ö´ú±íÕâ¸ösocketÔø¾­³É¹¦Á¬½Óµ½ÁËserver£¬µ«²¢²»±íʾÏÖÔÚÕâ¸öʱ¿ÌËüºÍserverÈÔ±£³ÖÁ¬½Ó״̬¡£
ÓÐÐĵÄÈ˻ᷢÏÖ£¬¼´Ê¹ÄãÒѾ­ÇжÏÁËserverºÍsocketÖ®¼äµÄÁ¬½Ó£¨±ÈÈçserver downµôÁË»òÍøÂçÖжÏÁË£©,µ«ÊÇÕâ¸öº¯ÊýÖ´ÐеĽá¹ûÈÔ¾ÉÊÇtrue¡£ËùÒÔ£¬ÎÒÈÏΪÕâ¸ö·½·¨²¢²»ÏñÎÒÃÇÏëÏóÖеÄÄÇô“¹ÜÓÔ¡£
¹ÖÒìÖ®Èý£º
¿¼ÂÇÕâÑùÒ»ÖÖÇé¿ö£º
1.socketºÍserver socketÒѾ­½¨Á¢ÁËÁ¬½Ó
2.µ«ÊÇÓÉÓÚÍøÂçÔ­Òò£¬Õâ¸öʱºòÁ¬½ÓÖжÏÁË¡£´ó¶àÊýϵͳ¶¼»áÓÐÒ»¸ö¶ÏÏßÖØÁ¬µÄ¹¦ÄÜ¡£
µ«Êǵ±Äãµ÷ÊÔʱ£¬Äã¿ÉÄܻᷢÏÖ£ºÍøÂç»Ö¸´Õý³£ºó£¬ÓÃÕâ¸ösocketÖØÐÂÁ¬½ÓserverSocket£¬È´ÔõôҲÁ¬²»ÉÏ¡£
ÔÚÕâÀïÎÒµÄ×ö·¨ÊÇ£º
socket=null;
//È»ºóн¨socket£¬¶ø²»ÊÇÓÃÔ­À´µÄÄǸösocket
socket = new Socket();
//½ÓÏÂÀ´£¬ÓÃÕâ¸ösocketÔÙÈ¥Á¬½ÓserverSocket£¬¾Í¿ÉÒԳɹ¦Á¬ÉÏÁË¡£


Ïà¹ØÎĵµ£º

תÌù£ºJavaÓïÑÔµÄÊ®´óÎÊÌâ¼°ÒýÉê˼¿¼

ת×Ô£ºhttp://blog.163.com/gordonkkk/blog/static/63425684200962795039630/
´ÓCSDNÉÏ¿´µ½Ò»ÆªÅúÆÀJavaÓïÑÔÖî¶àÎÊÌâµÄ·­ÒëÎÄÕ£¬Ô­ÎÄ×÷ÕßÊÇMario Fusco¡£ËûÖ¸³öÁËJavaÓïÑÔÂäºóÓÚʱ´ú£¬»ýÖØÄÑ·µµÄ10¸öÎÊÌâ¡£¿´¹ýÖ®ºóÒýÆðÁËÎÒµÄһЩÁªÏë¡£ÏÂÃæÁгöËûËù˵µÄ10´óÎÊÌâ¡£½Û»ÆÉ«×ÖÌåÊÇÎÒÒ»µãµã²»³ÉÊìµÄ˼¿¼¡£
1¡¢È±ÉÙ±Õ°ü£¨clos ......

java³ÌÐòÔ±ÃæÊԱر¸32Òªµã


µÚÒ»£¬Ì¸Ì¸final, finally, finalizeµÄÇø±ð¡£
¡¡final ÓÃÓÚÉùÃ÷ÊôÐÔ£¬·½·¨ºÍÀ࣬·Ö±ð±íʾÊôÐÔ²»¿É±ä£¬·½·¨²»¿É¸²¸Ç£¬À಻¿É¼Ì³Ð¡£finallyÊÇÒì³£´¦ÀíÓï¾ä½á¹¹µÄÒ»²¿·Ö£¬±íʾ×ÜÊÇÖ´ÐС£finalizeÊÇ ObjectÀàµÄÒ»¸ö·½·¨£¬ÔÚÀ¬»øÊÕ¼¯Æ÷Ö´ÐеÄʱºò»áµ÷Óñ»»ØÊÕ¶ÔÏóµÄ´Ë·½·¨£¬¿ÉÒÔ¸²¸Ç´Ë·½·¨ÌṩÀ¬»øÊÕ¼¯Ê± ......

¹ØÓÚJava¶ÁÈ¡xmlÎļþµÄѧϰ

Ò».javaÀà
package com.java.test;   
 
import org.w3c.dom.*;   
import javax.xml.parsers.*;   
import java.io.*;   
 
public class JavaReadXml {   
// Document¿ÉÒÔ¿´×÷ÊÇXMLÔÚÄÚ´æÖеÄÒ»¸ ......

JAVA±éÀúÒ»¸öÎļþ¼ÐÖеÄËùÓÐÎļþ

ÔÚʵ¼ÊÏîÄ¿Öиø¶¨Ò»Îļþ¼Ð£¬µÃµ½Õâ¸öÎļþ¼ÐÏÂËùÓеÄÎļþÕâÑùµÄÐèÇó²¢²»ÊǺܶ࣬¸ü¶àµÄÊDzéÕÒ»òÊÇɾ³ýijһ¾ßÌåµÄÎļþ
import java.io.File;
import java.util.ArrayList;
public class FileTest {
 private static ArrayList<String> filelist = new ArrayList<String>();
 
 public stati ......

»ñÈ¡java ÀàµÄ·¾¶

public class Path {
 //get class absolute address
 public String getPath() {
  String classPath = getClass().getName();
  if (classPath.indexOf(".") != -1) {
   classPath = classPath.substring(classPath.lastIndexOf(".") + 1,
     ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ