title: purpose of setURLStreamHandlerFactory in URL Class
body: <p>Can anyone explain to me the purpose and working of <code>setURLStreamHandlerFactory</code> in the <code>URL</code> class?</p>
  
  <p>I have a simple code snippet to connect to my HDFS using <code>URL</code> class in Java, which I have gone through in hadoop definitive guide.</p>
  
  <p>This is the code I've written:</p>
  
  <pre><code>public class HadoopFileSystemConnect {
  
      static {
          URL.setURLStreamHandlerFactory(new FsUrlStreamHandlerFactory());
      }
  
      public static void main(String[] args) throws IOException {
          URL url = new URL("hdfs://localhost:9000/employee_data.txt");
          InputStream in = url.openStream();
          IOUtils.copyBytes(in, System.out,4096,false);
      }
  }
  </code></pre>
  
  <p>Can anyone explain to me the purpose and working of the statement in the static block?</p>