Java tutorial
//package com.java2s; import java.net.URI; import java.net.URISyntaxException; public class Main { /** * This method returns an absolute URI using the given type * and namespace. If the type is already an absolute URI, it * is returned unchanged. * * @param type The type * @param namespace The namespace * * @return An absolute URI */ public static String convertTypeToURI(String type, String namespace) { if (type == null || type.equals("")) return null; URI absolute; try { absolute = new URI(type); } catch (URISyntaxException e) { return namespace + type; } if (absolute.getScheme() == null) { return namespace + type; } // may be already an absolute URI return type; } }