Created
August 28, 2017 02:23
-
-
Save dulimarta/ba2236a2db0525c548bfdeea50705e1f to your computer and use it in GitHub Desktop.
CS371 - Simple Web Client
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package edu.gvsu.cis; | |
public class WebClient { | |
public static void main(String[] args) { | |
String hostName = "localhost"; | |
int portNumber = 8000; | |
// Step 1: Create a socket that connects to the above host and port number | |
// Step 2: Create a PrintWriter from the socket's output stream | |
// Use the autoFlush option | |
// Step 3: Create a BufferedReader from the socket's input stream | |
// Step 4: Send an HTTP GET request via the PrintWriter. | |
// Remember to print the necessary blank line | |
// Step 5a: Read the status line of the response | |
// Step 5b: Read the HTTP response via the BufferedReader until | |
// you get a blank line | |
// Step 6a: Create a FileOutputStream for storing the payload | |
// Step 6b: Wrap the FileOutputStream in another PrintWriter | |
// Step 7: Read the rest of the input from BufferedReader and write | |
// it to the second PrintWriter. | |
// Hint: readLine() returns null when there is no more data | |
// to read | |
// Step 8: Remember to close the writer | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment