Describe the output of the following java programs

Describe the output of the following java programsi.import java.io.* ;import java.net.* ;public class TrivialBrowser {public static void main(String [] args) throws IOException {Socket s = new Socket(“www.grid2004.org”, 80) ;PrintWriter out = new PrintWriter(new OutputStreamWriter(s.getOutputStream())) ;out.print(“GET /spring2004/index.html HTTP/1.1rn”) ;out.print(“Host: www.grid2004.orgrnrn”) ;out.flush() ;BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream())) ;String line ;while((line = in.readLine()) != null)3System.out.println(line) ;}}( 4 Marks)ii. public static void main(String [] args) throws Exception {ServerSocket server = new ServerSocket(8080) ;while(true) {Socket sock = server.accept() ;BufferedReader in = new BufferedReader(new InputStreamReader(sock.getInputStream()) ;String header = in.readLine() ;. . . Skip over any other lines in request packet. . .String fileName = … path component from 2nd field ofheader … ;DataOutputStream out =new DataOutputStream(sock.getOutputStream()) ;if( … file fileNameexists…) {byte [] bytes = … contents of local file fileName… ;out.writeBytes(“HTTP/1.0 200 OKrn”) ;out.writeBytes(“Content-Length: ” + bytes.length + “rn”) ;out.writeBytes(“Content-Type: text/htmlrnrn”) ;out.write(bytes) ;} else { … Send HTTP error status …}}}

 
PLACE THIS ORDER OR A SIMILAR ORDER WITH BEST NURSING TUTORS TODAY AND GET AN AMAZING DISCOUNT

The post Describe the output of the following java programs appeared first on BEST NURSING TUTORS .
 
Do you need a similar assignment done for you from scratch? We have qualified writers to help you. We assure you an A+ quality paper that is free from plagiarism. Order now for an Amazing Discount!Use Discount Code “Newclient” for a 15% Discount!NB: We do not resell papers. Upon ordering, we do an original paper exclusively for you.

Open chat