⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 telephoneenquireserver.java

📁 JAVA网络编程电子书及源码
💻 JAVA
字号:
package net;

import java.io.*;
import java.net.*;
/**
 * 在这里插入类型说明。
 * 建立日期:(00-8-2 9:23:42)
 * @程序设计者:
 */
public class TelephoneEnquireServer {
/**
 * TelephoneEnquireServer 构造子注释。
 */
public TelephoneEnquireServer() {
	super();
}
/**
 * 启动该应用程序。
 * @param args 命令行参数数组
 */
public static void main(java.lang.String[] args) {
	 try{		 
		 boolean end=false ;
		 ServerSocket telserver=new ServerSocket(8000);
		 Socket  user=null;
		 String from_user_readLine;
		 System.out.println("The Telephone system for enquiring  is servering on port:"+telserver.getLocalPort());
		 while (!end){
		      user=telserver.accept();
		      DataInputStream  from_user_stream=new DataInputStream(new BufferedInputStream(user.getInputStream()));
		      PrintStream  to_user_stream=new PrintStream(new BufferedOutputStream(user.getOutputStream()));
		      while ((from_user_readLine=from_user_stream.readLine())!=null){
			     if (from_user_readLine.equals("y")){
				     to_user_stream.println("Telephone enquiring ended ....Thank you for your use");
				     end=true;
				     break;
			     }
			      if (from_user_readLine.equals("shanghai")){
				     
				            to_user_stream.println("Shanghai city area_tele_number:    021");
				            to_user_stream.flush();
				            continue;
			      }
				  if (from_user_readLine.equals("beijing")){
			      
				            to_user_stream.println("Beijng city area_tele_number:    010");
				            to_user_stream.flush();
				            continue;
				  }
				  if (from_user_readLine.equals( "ningbo")){
				   
				            to_user_stream.println("Ningbo city area_tele_number:    0574");
				            to_user_stream.flush();
				            continue;
				  }
				   if (from_user_readLine.equals( "yibin")){
				   
				            to_user_stream.println("Yibin city area_tele_number:    0834");
				            to_user_stream.flush();
				            continue;
				  }
				  if (from_user_readLine.equals(  "luzhou")){ 
				  
				             to_user_stream.println("Luzhou city area_tele_number:    0830");
				             to_user_stream.flush();
				             continue;
				  }
			      else{
			                  
			                 to_user_stream.println("you must write correctly please!");
			                 to_user_stream.flush();
			                 continue;
			                 
			      }
		      }
			     to_user_stream.close();
			     from_user_stream.close();
			     user.close();
		 }     
		 telserver.close();
		 
	 }catch(IOException e ) {System.err.println("Exception:"+e);}
}
			              
		  
		 
		 
		 
		 
		 
	 
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -