Содержание
- 2. What Is a URL? URL is an acronym for Uniform Resource Locator and is a reference
- 3. Creating a URL The easiest way to create a URL object is from a String: URL
- 4. Creating a URL Relative to Another A relative URL contains only enough information to reach the
- 5. URL addresses with Special characters Some URL addresses contain special characters, for example the space character.
- 6. URI The java.net.URI class automatically takes care of the encoding characters: URI uri = new URI("http",
- 7. MalformedURLException Each of the four URL constructors throws a MalformedURLException if the arguments to the constructor
- 8. Reading Directly from a URL After you've successfully created a URL, you can call the URL's
- 9. Reading Example public static void main(String[] args) throws Exception { URL oracle = new URL("http://www.oracle.com/"); BufferedReader
- 10. Connecting to a URL URL object's openConnection method allows to get a URLConnection object for a
- 11. Open Connection Example try { URL myURL = new URL("http://example.com/"); URLConnection myURLConnection = myURL.openConnection(); myURLConnection.connect(); }
- 12. Reading from a URLConnection Reading from a URLConnection instead of reading directly from a URL might
- 13. Reading Example public static void main(String[] args) throws Exception { URL oracle = new URL("http://www.oracle.com/"); URLConnection
- 14. Exercise: Read Statistics I Read file from http://www.ukrstat.gov.ua/express/expr2012/09_12/234.zip and save it in test.zip file * Infopulse
- 15. Exercise: Read Statistics II public static void main(String[] args) throws Exception{ URL expr = new URL("http://www.ukrstat.gov.ua/express/expr2012/09_12/234.zip");
- 16. Exercise: Read Statistics III try { out = new FileOutputStream("test.zip"); int c = -1; while ((c
- 17. Exercise: Read Statistics IV See 641GetWebFile project for the full text. * Infopulse Training Center
- 18. Providing Data to the Server Create a URL. Retrieve the URLConnection object. Set output capability on
- 20. Скачать презентацию