?? jwsconf.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 + -