hello阿诚

有兴趣留言交流

09-字符流和字节流

package com.yc.resp;

import com.example.servlet03Response.HelloServlet;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/ser01")
public class servlet01 extends HelloServlet {
    @Override
    protected void service(HttpServletRequest requestHttpServletResponse responsethrows ServletExceptionIOException {
        // getWriter() 字符 输出流 输出字符
//        PrintWriter writer = response.getWriter();
//        writer.write("hello");

        // 字节输出流  getOutputStream  输出一切数据
        ServletOutputStream out = response.getOutputStream();
        out.write("hi".getBytes());
    }
}


posted on 2021-07-15 14:24  陆秋明v  阅读(34)  评论(0编辑  收藏  举报

导航