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
Ïà¹ØÎĵµ£º
ListµÄÓ÷¨
List°üÀ¨List½Ó¿ÚÒÔ¼°List½Ó¿ÚµÄËùÓÐʵÏÖÀà¡£ÒòΪList½Ó¿ÚʵÏÖÁËCollection½Ó¿Ú£¬ËùÒÔList½Ó¿ÚÓµÓÐCollection½Ó¿ÚÌṩµÄËùÓг£Ó÷½·¨£¬ÓÖÒòΪListÊÇÁбíÀàÐÍ£¬ËùÒÔList½Ó¿Ú»¹ÌṩÁËһЩÊʺÏÓÚ×ÔÉíµÄ³£Ó÷½·¨£¬Èç±í1Ëùʾ¡£
±í1 List½Ó¿Ú¶¨ÒåµÄ³£Ó÷½·¨¼°¹¦ÄÜ
´Ó±í1¿ÉÒÔ¿´³ö£¬List½Ó¿ÚÌṩµÄÊʺÏÓÚ×ÔÉíµÄ ......
Ôڳɹ¦ÊµÏÖJavaµ÷ÓÃC++Ö®ºó£¬½ÓÏÂÀ´Ïëµ½ÄÜ·ñͨ¹ýJNAʵÏÖJavaµ÷ÓÃFortran£¬½ñÌìÊÔÑéÁËһϣ¬»¹ÊDZȽÏÈÝÒ׵ġ£
ÍøÉÏÓÐÒ»¸öJavaµ÷ÓÃF95µÄÀý×Ó£¬µ«ÊÇÎÒ¿¼ÂDz»½öҪʵÏÖF95µÄµ÷Ó㬻¹ÒªÊµÏÖF77µÄµ÷Óã¬ËùÒÔ·ÑÁËһЩÖÜÕÛ¡£
ÎÊÌâµÄ¹Ø¼üÔÚÓÚF77Ϊ¹ý³ÌÃû×Ô¶¯Ìí¼ÓÁËÒ»¸öβ²¿µÄÏ»®Ïߣ¬ËùÒÔsub1Õâ¸ö¹ý³Ì£¬µ½JavaÒ»¶Ë£¬¾Í±ä³ÉÁËsub1_£¬ ......
TIOBE
µÄ
±à³ÌÓïÑÔÅÅÃû°ñ£¬Ïë±Ø´ó¼Ò¶¼·Ç³£ÊìϤ£¬Ã¿Ô·¢²¼È«Çò±à³ÌÓïÑÔµÄÈȶȺÍÇ÷ÊÆ¡£ÔÚËÄÔ·ݷ¢²¼µÄÊý¾ÝÖУ¬CÓïÑÔÖÕÓÚ³¬¹ýJava³ÉΪNo.1£¬µ«ÕæÕýÈÃÈ˵£ÓÇ
µÄ£¬²¢²»ÊÇCµÄ¶á¹Ú£¬¶øÊÇJavaµÄ³ÖÐøÆ£Èõ£¬¸üÔã¸âµÄÊÇ£¬ËƺõûÓÐÄĸöÀÏ´óÕ¾³öÀ´Íì¾ÈÍÇÊÆ¡£
×÷ΪһÃûJava´ÓÒµÕߣ¬ÎÒÔÚÆóÒµÓ¦ÓÃÁìÓò×öÈí¼þ£¬´Ó¹¤×÷Öв¢Î´¸ÐÊܵ½Javaµ ......
È¡:
Cookie[] cookies = request.getCookies();
if(cookies!=null){
for(Cookie cookie : cookies){
if(cookie.getName().equals("mid")){
String mid = cookie.getValue();
}
}
}
´æ:
String mid ......