Created
February 10, 2015 02:01
-
-
Save bfritz/cb9037e7e7321f899168 to your computer and use it in GitHub Desktop.
Java class to cat a URL to System.out (not production code)
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
| import java.io.InputStream; | |
| import java.net.*; | |
| public class UrlFetch { | |
| public static void main(String... args) throws Exception { | |
| URL url = new URL(args[0]); | |
| URLConnection conn = url.openConnection(); | |
| InputStream is = conn.getInputStream(); | |
| while (is.available() > 0) { | |
| System.out.print((char) is.read()); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment