Remarks
This implements a (slightly restricted) Web server.
It creates a server socket listening to port 8080 on the local host.
It gets a socket connection from a client using the accept() method, and then gets the input stream from the socket using getInputStream().
We handle only “GET” requests; the second field will be the file name.
It reads the file and writes it to the output stream of the socket, in HTTP.
A real server would spawn a new thread to deal with each transaction. The main loop would return immediately to waiting on accept() .