List of usage examples for java.net URLDecoder decode
@Deprecated public static String decode(String s)
From source file:LauncherBootstrap.java
/** * The main method./*from w ww .j a v a 2 s.com*/ * * @param args command line arguments */ public static void main(String[] args) { try { // Try to find the LAUNCHER_JAR_FILE_NAME file in the class // loader's and JVM's classpath. URL coreURL = LauncherBootstrap.class.getResource("/" + LauncherBootstrap.LAUNCHER_JAR_FILE_NAME); if (coreURL == null) throw new FileNotFoundException(LauncherBootstrap.LAUNCHER_JAR_FILE_NAME); // Coerce the coreURL's directory into a file File coreDir = new File(URLDecoder.decode(coreURL.getFile())).getCanonicalFile().getParentFile(); // Try to find the LAUNCHER_PROPS_FILE_NAME file in the same // directory as this class File propsFile = new File(coreDir, LauncherBootstrap.LAUNCHER_PROPS_FILE_NAME); if (!propsFile.canRead()) throw new FileNotFoundException(propsFile.getPath()); // Load the properties in the LAUNCHER_PROPS_FILE_NAME Properties props = new Properties(); FileInputStream fis = new FileInputStream(propsFile); props.load(fis); fis.close(); // Create a class loader that contains the Launcher, Ant, and // JAXP classes. URL[] antURLs = LauncherBootstrap .fileListToURLs((String) props.get(LauncherBootstrap.ANT_CLASSPATH_PROP_NAME)); URL[] urls = new URL[1 + antURLs.length]; urls[0] = coreURL; for (int i = 0; i < antURLs.length; i++) urls[i + 1] = antURLs[i]; ClassLoader parentLoader = Thread.currentThread().getContextClassLoader(); URLClassLoader loader = null; if (parentLoader != null) loader = new URLClassLoader(urls, parentLoader); else loader = new URLClassLoader(urls); // Load the LAUNCHER_MAIN_CLASS_NAME class launcherClass = loader.loadClass(LAUNCHER_MAIN_CLASS_NAME); // Get the LAUNCHER_MAIN_CLASS_NAME class' getLocalizedString() // method as we need it for printing the usage statement Method getLocalizedStringMethod = launcherClass.getDeclaredMethod("getLocalizedString", new Class[] { String.class }); // Invoke the LAUNCHER_MAIN_CLASS_NAME class' start() method. // If the ant.class.path property is not set correctly in the // LAUNCHER_PROPS_FILE_NAME, this will throw an exception. Method startMethod = launcherClass.getDeclaredMethod("start", new Class[] { String[].class }); int returnValue = ((Integer) startMethod.invoke(null, new Object[] { args })).intValue(); // Always exit cleanly after invoking the start() method System.exit(returnValue); } catch (Throwable t) { t.printStackTrace(); System.exit(1); } }
From source file:Main.java
public static String urlDecode(String in) { return URLDecoder.decode(in); }
From source file:Main.java
public static String decodeURL(String str) { return URLDecoder.decode(str); }
From source file:Main.java
private final static String parseObjKey(String path, String url_type) { path = URLDecoder.decode(path); String objKey = ""; int p = 0;/*w ww.j a va 2s.com*/ String str = ""; String[] tmp = null; p = path.indexOf(url_type) + url_type.length(); str = path.substring(p); if (str.contains("?")) { tmp = str.split("?"); objKey = tmp[0]; } else { objKey = str; } return objKey; }
From source file:Main.java
public static String getFileNameFromURL(String s) { if (s == null) { return null; }//from w w w . j a v a 2 s. c o m String s1 = URLDecoder.decode(s); if (s1.indexOf("?") >= 0) { s1 = s1.substring(0, s1.indexOf("?")); } return s1.substring(1 + s1.lastIndexOf(File.separator), s1.length()); }
From source file:Main.java
public static Bundle decodeUrl(String s) { Bundle params = new Bundle(); if (s != null) { String array[] = s.split("&"); for (String parameter : array) { String v[] = parameter.split("="); // YG: in case param has no value if (v.length == 2) { params.putString(URLDecoder.decode(v[0]), URLDecoder.decode(v[1])); } else { params.putString(URLDecoder.decode(v[0]), " "); }/*w ww . java 2 s. co m*/ } } return params; }
From source file:Main.java
/** * Extracts a desired string given a string and a pattern using regex * //from ww w . ja v a 2 s . c om * @param response the string to extract from * @param pattern the regex pattern used to extract * * @return desired extracted string */ @SuppressWarnings("deprecation") public static String extract(String response, Pattern pattern) { String extraction = null; Matcher matcher = pattern.matcher(response); if (matcher.find() && matcher.groupCount() >= 1) { extraction = URLDecoder.decode(matcher.group(1)); } return extraction; }
From source file:Main.java
/** * @param url/*from w w w . j a v a 2s . c o m*/ * @return bundle that contains key-value entries of the url query and fragment. */ public static final Bundle getUrlParameters(final String url) { final Bundle bundle = new Bundle(); final String[] separated = url.split("\\?"); if (separated.length > 1) { final String query = separated[1]; final String[] params = query.split("[&#]"); for (final String param : params) { final String[] keyvalue = param.split("="); final String key = URLDecoder.decode(keyvalue[0]); String value = null; if (keyvalue.length > 1) { value = URLDecoder.decode(keyvalue[1]); } bundle.putString(key, value); } } return bundle; }
From source file:Main.java
@SuppressWarnings("deprecation") public static String decodeSubscriptionURL(final String url) { if (url.startsWith("feed/")) { return "feed/" + URLDecoder.decode(url.substring(5)); } else {/*from w w w. j ava 2s. c om*/ return url; } }
From source file:Main.java
/** * Decode parameters contained in the provided String and generate a {@link Bundle} associating * parameters name and values./*from ww w . j a v a 2s.c o m*/ * * @param url * Url that we decode parameters from. * @return Bundle containing decoded parameters. */ public static Bundle decodeUrl(String url) { Bundle bundle = new Bundle(); if (!TextUtils.isEmpty(url) && url.indexOf("?") != -1) { String urlParameters = url.substring(url.indexOf("?") + 1); String[] parameters = urlParameters.split("&"); for (String parameter : parameters) { String[] keyValue = parameter.split("="); if (keyValue.length == 2) { bundle.putString(URLDecoder.decode(keyValue[0]), URLDecoder.decode(keyValue[1])); } } } return bundle; }