View RSS Feed

Recent Blogs Posts

  1. Java Networking: URL + URLConnection

    by , 04-25-2012 at 11:31 PM
    Two classes are present in java.net package. URLConnection class & URL class.Client connections are created by these classes to the web servers. Here is a code given as an example:
    Java Code:
    URL url = new URL("http://test.com");
    
    URLConnection urlConnection = url.openConnection();
    InputStream input = urlConnection.getInputStream();
    
    int data = input.read();
    while(data != -1){
        System.out.print((char) data);
        data =
    ...
    Categories
    Tutorial
  2. Fetching HTML content of a Web Page

    by , 11-10-2011 at 05:46 PM (My Java Tips)
    Sometimes you are required to fetch and store data from web pages. If there are too many pages to parse, then obviously this cannot be done manually. Java provides support for web text extraction.


    The approach is simple. You have to fetch all the HTML contents of a webpage and then you can write your own parser to extract the required info. For example: you might be asked to only store the text in table data tag with caption Hobbies. So you will store all the HTML contents of web ...