java 通过浏览器访问本地服务器打开一个html文件总是找不到路径

文件路径正确,并且绝对路径和相对路径都已经尝试,为啥一直报相同错误。

package day29;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class BS {
    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(8888);
        while (true){
            Socket ac = ss.accept();
            new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        InputStream is = ac.getInputStream();
                        BufferedReader bf = new BufferedReader(new InputStreamReader(is));
                        String s = bf.readLine();
                        System.out.println(s);
                        String[] s1 = s.split(" ");
                        String sub = s1[1].substring(1);
                        System.out.println(sub);
                        FileInputStream fis = new FileInputStream(sub);
                        OutputStream os = ac.getOutputStream();
                        // 写入HTTP协议响应头,固定写法
                        os.write("HTTP/1.1 200 OK\r\n".getBytes());
                        os.write("Content-Type:text/html\r\n".getBytes());
                        // 必须要写入空行,否则浏览器不解析
                        os.write("\r\n".getBytes());
                        int len = 0;
                        byte[] b = new byte[1024];
                        while ((len = fis.read(b)) != -1){
                            os.write(b);
                            fis.close();
                            ac.close();
                        }
                    }catch (IOException E){
                        E.printStackTrace();
                    }

                }
            }).start();

        }
    }
}

图片说明

你访问的时候
http://localhost:8888/index.html
你在读取文件的地方加上你地址栏输入的 文件的文件夹路径

FileInputStream fis = new FileInputStream("E:\\test\\web\\" + sub);

就可以了