Here you can find the source of getUrl(String serverName, String docid, String pageid)
public static String getUrl(String serverName, String docid, String pageid) throws MalformedURLException, IOException
//package com.java2s; /*/*w w w.j a v a 2s . c o m*/ * This file is part of TILT. * * TILT is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * TILT is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with TILT. If not, see <http://www.gnu.org/licenses/>. * (c) copyright Desmond Schmidt 2014 */ import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; public class Main { public static String getUrl(String serverName, String docid, String pageid) throws MalformedURLException, IOException { String url = "http://" + serverName + "/pages/uri_template"; String template = getFromUrl(url); if (template.contains("{pageid}")) template = template.replace("{pageid}", pageid); if (template.contains("{docid}")) template = template.replace("{docid}", docid); return template; } public static String getFromUrl(String url) throws MalformedURLException, IOException { URL loc = new URL(url); URLConnection pagesService = loc.openConnection(); InputStream is = pagesService.getInputStream(); StringBuilder sb = new StringBuilder(); while (is.available() != 0) { byte[] data = new byte[is.available()]; is.read(data); sb.append(new String(data)); } is.close(); return sb.toString(); } }