Java tutorial
//package com.java2s; /* Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved. Available via Academic Free License >= 2.1 OR the modified BSD license. see: http://dojotoolkit.org/license for details */ import java.net.MalformedURLException; import java.net.URL; public class Main { private static URL createURL(String url) { URL requestURL; try { requestURL = new URL(url); return requestURL; } catch (MalformedURLException e) { try { requestURL = new URL("http://localhost:8080" + url); return requestURL; } catch (MalformedURLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } return null; } }