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

Java ÀûÓÃÌ×½Ó×ÖSocketʵÏÖ¼òµ¥µÄ·þÎñÆ÷Óë¿Í»§¶ËͨÐÅ

ÎÒÃÇҪʵÏֵľßÌ幦ÄÜÊÇ£º
ÀûÓÃSocketÀàºÍServerSocketÀà±àдһ¸öC/S³ÌÐò£¬ÊµÏÖC/SͨÐÅ¡£
¿Í»§¶ËÏò·þÎñÆ÷¶Ë·¢ËÍTimeÃüÁ·þÎñÆ÷¶Ë½ÓÊܵ½¸Ã×Ö·û´®ºó½«·þÎñÆ÷¶Ëµ±Ç°Ê±¼ä·µ»Ø¸ø¿Í»§¶Ë£»¿Í»§¶ËÏò·þÎñÆ÷¶Ë·¢ËÍExitÃüÁ·þÎñÆ÷¶ËÏò¿Í»§¶Ë·µ»Ø“Bye”ºóÍ˳ö¡£
ÌâÄ¿±È½Ï¼òµ¥µÄ£¬ÎÒÃÇÖ±½ÓÀ´¿´´úÂë°É£º
Ê×ÏÈÊÇ·þÎñÆ÷¶ËµÄʵÏÖ£º
 import java.net.ServerSocket;
import java.net.Socket;
import java.io.*;
import java.text.DateFormat;
import java.util.Date;//ʱ¼ä
//import java.util.Calendar;
public class Server {
public static void main(String args[]){
try{
ServerSocket server = new ServerSocket(11111);//´´½¨·þÎñÆ÷Ì×½Ó×Ö
System.out.println("·þÎñÆ÷Æô¶¯Íê±Ï");

System.out.println("µÈ´ý¿Í»§¶ËÁ¬½Ó...");
Socket socket = server.accept();//µÈ´ý¿Í»§¶ËÁ¬½Ó

BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));//»ñµÃ¿Í»§¶ËµÄÊäÈëÁ÷
//OutputStreamWriter out = new OutputStreamWriter(socket.getOutputStream());//»ñµÃ¿Í»§¶ËÊä³öÁ÷
PrintWriter out = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()),true);//»ñµÃ¿Í»§¶ËÊä³öÁ÷)
if(socket.isConnected()){
System.out.println("¿Í»§¶ËÃû³ÆÎª"+socket.getInetAddress().getHostAddress()+" Á¬½Ó³É¹¦£¡");
//out.write("Á¬½Ó³É¹¦\n");
out.println("Á¬½Ó³É¹¦");
}

while(true){
String str = reader.readLine();
if(str.equals("Time")){//¿Í»§¶ËÇëÇóʱ¼äÊý¾Ý
Date date = new Date();
// Calendar cal = Calendar.getInstance();
System.out.println("¿Í»§¶ËÇëÇóµ±Ç°Ê±¼ä");
DateFormat format = DateFormat.getDateInstance();
//out.write(format.format(date));//¸ñʽ»¯Êä³öʱ¼ä
out.println(format.format(date));
}
else if(str.equals("exit")){//Í˳ö
//out.write("bye");
out.println("bye");
System.out.println("Á¬½Ó¶Ï¿ª");
break;
}
else{
System.out.println("Êý¾Ý£º"+str);
}
}
}catch(IOException e){
e.pr


Ïà¹ØÎĵµ£º

JavaÖÐhashCode()·½·¨µÄ˵Ã÷

ÓÐÐí¶àÈËѧÁ˺ܳ¤Ê±¼äµÄJava£¬µ«Ò»Ö±²»Ã÷°×hashCode·½·¨µÄ×÷Óã¬
ÎÒÀ´½âÊÍһϰɡ£Ê×ÏÈ£¬ÏëÒªÃ÷°×hashCodeµÄ×÷Óã¬Äã±ØÐëÒªÏÈÖªµÀJavaÖеļ¯ºÏ¡£¡¡¡¡
×ܵÄÀ´Ëµ£¬JavaÖеļ¯ºÏ£¨Collection£©ÓÐÁ½À࣬һÀàÊÇList£¬ÔÙÓÐÒ»ÀàÊÇSet¡£
ÄãÖªµÀËüÃǵÄÇø±ðÂð£¿Ç°Õß¼¯ºÏÄÚµÄÔªËØÊÇÓÐÐòµÄ£¬ÔªËØ¿ÉÒÔÖØ¸´£»ºóÕßÔªËØÎÞÐò£¬µ«ÔªËز» ......

Âþ̸£ºÑ¡ÔñJava Web¿ª·¢Õæ²»ÈÝÒ×

ƽʱÔÚ¹¤×÷µÄʱºò£¬×ÜÊǾõµÃ¸Õ±ÏÒµµÄͬÊÂÃǶԼ¼ÊõµÄÀí½â²»µ½Î»£¬ÖªÆäÈ»¶ø²»ÖªÆäËùÒÔÈ»¡£¿ÉÊÇ£¬¾²ÏÂÐÄÀ´ÏëÒ»Ï룬ÕâÒ²²»ÄÜÈ«¹ÖËûÃÇ£¬²»ÊÇÐÂÈËÃDz»°®
ѧ£¬¶øÊÇÏÖÈç½ñJava Web¿ª·¢µÄÈ·ºÜ·±¸´¡£±íÃæÉÏ¿´£¬ÏÖÔÚ»áJavaµÄÈ˶àÈçţ룬SSH ºÞ²»µÃÊÇÿ¸ö java ¿ª·¢Åàѵ¿ÎµÄ±ØÑ¡ÏîÄ¿£¬µ«
WEB ¿ª·¢µÄÃż÷£¬ÕæµÄ²»µÍ¡£µ±È»£¬ÎÒ˵²»µÍ£ ......

JavaÓëActionScriptµÄSocket(1)

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package cn.vicky.socket;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Vector;
/**
*
* @author Vicky
* ¹ã²¥Àà
*/
public class BMana ......

[JAVA]ÐÞ¸ÄJavaÎļþ²»ÓÃÖØÆôTomcat·þÎñµÄ·½·¨

ÐÞ¸ÄJavaÎļþ²»ÓÃÖØÆôTomcat·þÎñµÄ·½·¨
      ÔÚʹÓÃEclipse+Tomcat¿ª·¢JavaÏîÄ¿µÄʱºò³£³£»áÅöµ½ÕâÑùµÄÇé¿ö£¬ÒÑÐÞ¸ÄJavaÎļþTomcat¾Í»á×Ô¶¯ÖØÆô£¬½ÓÏÂÀ´¾ÍÊÇÂþ³¤µÄµÈ´ý·þÎñÖØÆôÍê±Ï¡£ÄÇÆäʵ´ó¶àÊýµÄJavaÎļþÐÞ¸ÄÊÇûÓбØÒªÖØÆô·þÎñµÄ£¬Ö»ÓÐÒ»Ð©ÌØ¶¨µÄJavaÎļþ£¬±ÈÈç˵ֻÓÐÖØÆô·þÎñµÄʱºò²Å»áµ÷Ó ......

»ùÓÚmvcµÄjava webÉè¼ÆÓ뿪·¢


µÚ1Õ strutsÓëjava webÓ¦Óüò½é
1.1 java webÓ¦ÓøÅÊö
1.2 web×é¼þµÄÈýÖÖ¹ØÁª¹ØÏµ
1.3 muv¸ÅÊö
1.4 struts¸ÅÊö
1.4.1 strutsʵÏÖmvcµÄ»úÖÆ
ÔÚstruts¿ò¼ÜÖУ¬Ä£ÐÍÓÉʵÏÖÒµÎñÂß¼­µÄjavabean»òejb×é¼þ¹¹³É£¬¿ØÖÆÆ÷ÓÉ
ActionServletºÍActionÀàʵÏÖ£¬ÊÓͼÓÉÒ»×éjspÎļþ¹¹³É¡£
1.ÊÓͼ
ÊÓͼ¾ÍÊÇjspÎļþ¡£ÔÚÕâЩjspÎļþ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ