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

JavaÍøÂç±à³Ì³õ²½

JavaÍøÂç±à³Ì³õ²½
Kagula
2009-11-23
¹Ø¼ü´Ê
Java  Socket  DataInputStream   DataOutputStream
¸ÅÒª
    ʹÓÃJavaͬ²½IOÓ¦ÓóÌÐò¿â£¬ÊµÏÖCS½á¹¹ÍøÂç±à³Ì¡£
ÕýÎÄ
ʹÓÃSocketÀ´½¨Á¢ÍøÂçÁ¬½Ó£¬Ê¹ÓÃDataInputStream¡¢DataOutputStreamÀ´´æÈ¡ÍøÂçÁ÷¡£
 
¿Í»§¶Ë²¿·Ý
µÚÒ»²½£º½¨Á¢ÍøÂçÁ¬½Ó¶ÔÏ󣬺ÍÍøÂçÁ÷ÊäÈëÊä³ö¶ÔÏó
Socket c = new Socket(InetAddress.getByName("192.168.0.144"),6009);
dis      = new DataInputStream(c.getInputStream());
dos      = new DataOutputStream(c.getOutputStream());
µÚ¶þ²½£º¶ÁдÍøÂçÁ÷
д×Ö·û´®ÓÃÏÂÃæµÄ´úÂë
dos.writeUTF(list.get(i).toString());
dos.flush();
д¶þ½øÖÆÊý¾Ý²ÉÓÃÏÂÃæµÄ´úÂë
//byte[] b = new byte[nnL];
dos.write(b,0,nnL);
dos.flush();
ÕâÀïҪעÒâµÄÊÇwriteº¯ÊýµÄµÚ¶þ¸ö²ÎÊý£¬Ö¸µÄÊÇ»º´æÇøÆðʼλÖã¬nnLÖ¸µÄÊÇ»º´æÇøÖÐÊý¾ÝµÄ³¤¶È¡£b»º´æµÄ´óС½¨ÒéΪ1KB£¬¹ý´ó»áµ¼Ö²¿·ÝÊý¾Ý·¢ËͳöÈ¥ÁË£¬µ«ÊǽÓÊÕµ½Ã»ÓÐÊÕµ½ÓÐЧµÄÊý¾Ý¡£
¶Á×Ö·û´®ÓÃÏÂÃæµÄ´úÂë
String sR = dis.readUTF();
¶Á¶þ½øÖÆÊý¾ÝÓÃÏÂÃæµÄ´úÂë
 
Dis.read(b,0,nnL);
ÕâÀïÐèҪעÒ⣬·¢ËͶËͬ½ÓÊÕ¶ËÖ®¼ä£¬ÍøÂçÁ÷´æÈ¡º¯ÊýҪƥÅ䣬Êý¾Ý³¤¶ÈҲҪƥÅ䣬·ñÔò»á×èÈû¡£
µÚÈý²½£º¹Ø±ÕÁ¬½Ó¡£´úÂëÈçÏÂ
Dis.close();
Dos.close();
C.close();
·þÎñ¶Ë²¿·Ý
     µÚÒ»²½£º½¨Á¢ServerSocket¶ÔÏ󣬵õ½¿Í»§¶ËµÄÁ¬½ÓÇëÇ󣬴úÂëÈçÏ£º
ServerSocket server = new ServerSocket(listenPort);
Socket incomingConnection = null;
while(true) {
   incomingConnection = server.accept();
   incomingConnection.setSoTimeout(9*60*1000);
   handleConnection(incomingConnection);
}
ÆäÖУ¬listenPortÊÇÕìÌý¶Ë¿ÚΪÕûÐÍ¡£¿Í»§Í¬·¢ËÍÇëÇóºó£¬·þÎñ¶ËºÍ¿Í»§¶Ë½¨Á¢Á¬½Ó£¬server.accept·µ»Øsocket¡£
ÀûÓÃsocket£¬µÃµ½¶ÁдÍøÂçÁ÷Êý¾ÝµÄ¶ÔÏó£¬ÆäËüͬ¿Í»§¶ËµÄ±à³Ì·½Ê½¡£ÔÚÍê³É¶ÁдºóÄãÒ²ÐèÒªµ÷ÓÃsocketʵÀýµÄcloseº¯Êý£¬¶Ï¿ªÍ¬¿Í»§¶ËµÄÁ¬½Ó¡£SocketʵÀýµÄsetSoTimeoutÉèÖ㬱£Ö¤ÔÚ¾ÅÃëºó×Ô¶¯¹Ø±Õͬ¿Í»§¶ËµÄÁ¬½Ó¡£
 
 
×ܽ᣺
Ïà±ÈC++£¬JavaÌṩµÄAPI·Ç³£ÈÝÒ×ʹÓᣵ«ÊÇҲҪעÒ⼸¸öÎÊÌâ¡£[1]·þÎñ¶ËºÍ¿Í»§¶ËµÄ¶Áдº¯Êý±ØÐëҪƥÅä¡£[2]·þÎñ¶Ëͬ¿Í»§¶ËÖ®¼ä¶


Ïà¹ØÎĵµ£º

sql 2005 ´æ´¢¹ý³Ì·ÖÒ³ java ´úÂë

 create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',         
@pagesize int output,--ÿҳÏÔʾ¼Ç¼ÌõÊý
@currentpage int output,--µÚ¼¸Ò³
@orderid nvarchar(50),--Ö÷¼üÅÅÐò
@sort int,--ÅÅÐò·½Ê½£¬1±íʾÉýÐò£¬0±íʾ½µÐòÅÅÁÐ ......

java dnd

dndÊÇdrag and dropµÄËõд.
javaÖеÄdndÖ÷ÒªÉæ¼°µ½3¸öÀà:TransferHandler(ÓÃÀ´´¦ÀíÊý¾ÝµÄÍϷŹý³Ì),Transferable(ÓÃÀ´°ü×°ÍϷŵÄÊý¾Ý),ºÍDataFlavor(ÓÃÀ´±íʾÍϷŵÄÊý¾ÝµÄÀàÐÍ).ÏÂÃæÀ´½éÉÜÕâ3¸öÀàµÄ·½·¨
1.javax.swing.TransferHandler
ËüÓÐÁ½¸ö¹¹Ô캯Êý:
TransferHandler() ×ÓÀàµÄ±ã½Ý¹¹Ôì·½·¨¡£
TransferHandler(St ......

Java СÀý×Ó£ºÏÂÔز¢±£´æÍøÂçС˵

±¾Ê¾Àý´ÓÍøÉÏÏÂÔØÒ»±¾Ð¡Ëµ£¬²¢±£´æΪ UTF-8 ¸ñʽ¡£
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.net.MalformedURLException; ......

java

1  String ºÍStringBufferµÄÇø±ð
      JAVAƽ̨ÌṩÁËÁ½¸öÀࣺStringºÍStringBuffer£¬ËüÃÇ¿ÉÒÔ´¢´æºÍ²Ù×÷×Ö·û´®£¬¼´°üº¬¶à¸ö×Ö·ûµÄ×Ö·ûÊý¾Ý¡£StringÀàÌṩµÄÊýÖµ²»¿É¸Ä±äµÄ×Ö·û´®¡£StringBufferÀàÌṩµÄ×Ö·û´®½øÐÐÐ޸ġ£µ±ÖªµÀ×Ö·ûÊý¾ÝÒª¸Ä±äµÄʱºòÄã¾Í¿ÉÒÔʹÓÃStringBuffer£¬¿ÉÒÔʹÓÃStri ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ