📄 template.java
字号:
package freech.layout;
import java.io.*;
import freech.core.*;
public class Template {
public Template(){
}
public void responseFile(PrintStream out,String type) {
File f =null;
StringBuffer sb = new StringBuffer(Server.svr .getBASE_PATH());
if (type.equals( "index")){
sb.append( "/index.html");
f = getFile(sb.toString());
}else if (type.equals( "frameset")){
sb.append( "/frameset.html");
f = getFile(sb.toString());
}else if (type.equals( "talk")){
sb.append( "/talk.html");
f= getFile(sb.toString());
}else if(type.equals( "mainchat")){
sb.append( "/mainchat.html");
f=getFile(sb.toString() );
}
try {
DataInputStream in = new DataInputStream(new FileInputStream(f));
int len = (int)f.length() ;
byte buf[] = new byte[len];
in.readFully( buf);//将文件读入缓存
System.out.println("filelen="+len );
out.println("HTTP/1.0 200 OK");
out.println("MIME_version:1.0");
out.println("Content_Type:text/html");
out.println("Content_Length:"+len);
out.println("");
out.write( buf,0,len);
in.close() ;
long m1=1; //延时
while (m1<11100000) {m1++;}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private File getFile(String path){
File f=null;
try {
f = new File(path);
if(!f.exists() ){
System.out.println("文件不存在");
}else{
System.out.println(path+" requested.");
}
} catch (RuntimeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return f;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -