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

📄 response.java

📁 用JAVA开发
💻 JAVA
字号:
package cn.netjava.feeserver.servletcontainer;

import java.io.*;

public class Response {

	/**
	 * 构造器
	 * @param output:输出流对象
	 */
	public Response(java.io.OutputStream output){
		this.output=output;
	}
	
	/**
	 * 将消息内容发送到客户端
	 * @param content:消息内容
	 */
	public void setContent(String content){
		try{
		output.write(content.getBytes());
		}catch(Exception ef){
			LogManager.error("send msg 2 client error :"+content+ "  error :"+ef);
		}
	}
	
    /**
     * 发送静态文件到客户端
     * @param filePath:文件全路陉
     */
	 public void sendStaticResource(String filePath){
		 try{
		 java.io.FileInputStream fis=null;
		 File file=new File(filePath);
		 fis=new FileInputStream(file);
		 int ch=-1;
		 while((ch=fis.read())!=-1){
			 output.write(ch);
		 }
		
		 }catch(Exception ef){
			 LogManager.error("sendStaticResource error :"+filePath+ "  error :"+ef);
		 }
	 }
	
	
	private java.io.OutputStream output;
}

⌨️ 快捷键说明

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