日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 前端技术 > HTML >内容正文

HTML

如何判断浏览器的请求头是不是结束

發(fā)布時間:2025/7/14 HTML 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 如何判断浏览器的请求头是不是结束 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
\r\n\r\n好像是結(jié)束符package?com.maple.detail3;
?
?import?java.io.FileInputStream;
?import?java.io.FileNotFoundException;
?import?java.io.IOException;
?import?java.io.InputStream;
?import?java.io.OutputStream;
?import?java.io.PrintWriter;
?import?java.net.ServerSocket;
?import?java.net.Socket;
?
?public?class?TcpServer3?{
?????public?static?void?main(String[]?args)?throws?Exception?{
?
?????????ServerSocket?serverSocket=new?ServerSocket(10000);
?????????Thread?t=null;
?????????while(true)
?????????{
?????????????Socket?socket=serverSocket.accept();
??????????????t=new?Thread(new?ReadPic(socket));
??????????????t.start();
?????????}
?????}
?
?}
?
?class?ReadPic?implements?Runnable
?{
?????Socket?socket=null;
?????
?????public?ReadPic(Socket?socket)?{
?????????this.socket=socket;
?????}
?
?????@Override
?????public?void?run()?{
?????????try?{
?????????????OutputStream?outputStream=socket.getOutputStream();
?????????????InputStream?inputStream=new?FileInputStream("c:/2.png");
?????????????
?????????????InputStream?socketInputStream=socket.getInputStream();
?????????????
?????????????
?????????????byte[]?buf=new?byte[1024];
?????????????int?len=0;
?????????????
?????????????while((len=socketInputStream.read(buf))!=-1)
?????????????{
?????????????????String?line=new?String(buf,0,len);
?????????????????System.out.println(line.length()+"??"+line);
?????????????????if(line.endsWith("\r\n\r\n"))
?????????????????{
?????????????????????System.out.println("game?is?over");
?????????????????????break;
?????????????????}
?????????????}????????????
?????????????System.out.println("kkkkkkkkkkkkkkkk");
?????????????while((len=inputStream.read(buf))!=-1)
?????????????{
?????????????????outputStream.write(buf,0,len);
?????????????????outputStream.flush();
?????????????}
?????????????socket.close();
?????????}?catch?(Exception?e)?{
?????????????e.printStackTrace();
?????????}
?????}
?}

??

轉(zhuǎn)載于:https://www.cnblogs.com/passer1991/archive/2012/11/01/2749005.html

總結(jié)

以上是生活随笔為你收集整理的如何判断浏览器的请求头是不是结束的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。