Here you can find the source of encodeURI(URI uri)
public static String encodeURI(URI uri)
//package com.java2s; /*/*from w ww. j a v a2 s. c o m*/ * Copyright (c) 2015 Eike Stepper (Berlin, Germany) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Eike Stepper - initial API and implementation */ import java.io.UnsupportedEncodingException; import java.net.URI; import java.net.URLEncoder; public class Main { public static String encodeURI(URI uri) { return encodeURI(uri.toString()); } public static String encodeURI(String uri) { try { uri = URLEncoder.encode(uri, "UTF-8"); //$NON-NLS-1$ } catch (UnsupportedEncodingException ex) { // UTF-8 should always be available. } return uri; } }