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

📄 jwsconf.java

📁 用JAVA编写的一个聊天程序
💻 JAVA
字号:
package http;
import java.io.*;
import java.util.*;


public  class jwsconf{

  private  static  Hashtable mimeType;
  private  static  Hashtable HttpConf;
  
  public jwsconf(){
  	mimeType = new Hashtable();
  	HttpConf = new Hashtable();  	  	
  	ConfConstrue(mimeType , "../conf/mime.types",'R');
  	ConfConstrue(HttpConf , "../conf/httpd.conf",'L');  	
  }//end jwsconf()

  private void ConfConstrue (Hashtable Table, String filename, char type){
	String FileLine="";
	int j=0,beginIndex=-1,endIndex=-1;
	String str[]= new String[50];	
      try{
 	   BufferedReader rfStream=new BufferedReader( new FileReader(filename) );
	   while (rfStream.ready()){
       	             	      
       	      FileLine = rfStream.readLine();
       	      FileLine+="\n";
       	      str[1]=null;
	      
	 	if (!FileLine.equals("")){
	 		
	 	    for (int i=0;i<FileLine.length();i++ ){

	 			      	 				
		 	   if (  beginIndex!=-1 && ( FileLine.charAt(i)==' ' || FileLine.charAt(i)=='\t' || FileLine.charAt(i)=='\n' || FileLine.charAt(i)=='\r' ) ){
				  if (endIndex==-1){
				    endIndex=i;
				    if (beginIndex!=endIndex){
				      str[j++]=FileLine.substring(beginIndex, endIndex);
				    }
	 			    beginIndex=-1;
	 			    endIndex=-1;
	 			  }

	 		   }

		 	   if (  FileLine.charAt(i)!=' ' && FileLine.charAt(i)!='\t' ){
		 				 			    
	 			   if (beginIndex==-1) {
	 			              if (FileLine.charAt(i)=='#'){
       	       					break;}

	 			         beginIndex=i;
         			         continue;}//end if
         			           			        
  			   }//end if

	 			      	 				
	 	    }//end for
	 			 		
	 	}//end if

		if (type=='R'){
		  for (int i=1;i<j;i++){
	    	    Table.put(str[i],str[0]);
	    	  }
		}//end if

		if (type=='L'){
		   
		   if (j>2){
		      String[] tmp=new String[j-1];
		      int p=0;
		      for (int i=1;i<j;i++) {
		  	  tmp[p++]=str[i];}		  	
	    	          Table.put(str[0].toLowerCase(),tmp);	    	      
	    	    }else{
	    	     if ( str[1]==null){
	    	     	  str[1]="";}	    	     	  
	    	    Table.put(str[0].toLowerCase(),str[1]);}

		}//end if

 	       beginIndex=-1;
	       endIndex=-1;
	       j=0;

	   }// end while
	}
	catch(IOException E){}		
  	
  }//end ConfConstrue();

public static String GetMime(String RequestSouc){
	String Getmime;
	RequestSouc  = RequestSouc.substring( RequestSouc.lastIndexOf('.')+1,RequestSouc.length() );
			
	Getmime=(String)mimeType.get(RequestSouc);

	if (Getmime==null){
		return HttpConf("DefaultType");
	}

	return "Content-Type: " + Getmime+";";
}

public static String HttpConf(String key){	
	return (String)HttpConf.get(key.toLowerCase());
}

public static String[] HttpConfM(String key){
	return (String[])HttpConf.get(key.toLowerCase());
}



}//end class jwsconf

⌨️ 快捷键说明

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