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 request, HttpServletResponse response) throws ServletException, IOException {
// getWriter() 字符 输出流 输出字符
// PrintWriter writer = response.getWriter();
// writer.write("hello");
// 字节输出流 getOutputStream 输出一切数据
ServletOutputStream out = response.getOutputStream();
out.write("hi".getBytes());
}
}