Java Code Examples for java.net.URL#endsWith()

The following examples show how to use java.net.URL#endsWith() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MiscellaneousFunctions.java    From kspl-selenium-helper with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Thiss function is used to get file name from given URL
 * @param URL -Enter URL
    * @return -Returns file name
    */
public static String getFileNameFromURL(String URL) {
	String fileName = "";
	String[] path = URL.split("/");
	if (URL.endsWith("/"))
		fileName = path[path.length - 1];
	else {
		String[] fileNameSplit = path[path.length - 1].split(".");
		if (fileNameSplit.length > 0)
			fileName = path[path.length - 1];
	}
	return fileName;
}
 
Example 2
Source File: Downloader.java    From AOSPBrowserInstaller with GNU General Public License v3.0 5 votes vote down vote up
protected void onPreExecute() {
    if (overrideFile)
        outputFile.delete();
    if (!outputFile.getParentFile().exists()) {
        outputFile.getParentFile().mkdir();
    }

    if (!URL.endsWith("/"))
        URL = URL + "/";
    if (!URL.startsWith("http://")
            && !URL.startsWith("https://"))
        URL = "http://" + URL;
    if (!hide) {
        downloadDialog = new ProgressDialog(mContext);
        downloadDialog.setTitle(mContext.getResources().getString(R.string.connecting));
        downloadDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        downloadDialog.setCancelable(false);
        downloadDialog.setMessage(URL);
        if (cancelable)
            downloadDialog.setButton(DialogInterface.BUTTON_NEGATIVE, mContext.getString(R.string.cancel), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    thisDownloader.cancel(false);
                    if (outputFile.exists())
                        outputFile.delete();
                }
            });
        downloadDialog.show();
    }
}
 
Example 3
Source File: StringUtil.java    From cerberus-source with GNU General Public License v3.0 5 votes vote down vote up
public static String addQueryString(String URL, String queryString) {
    String result = "";
    if (isNullOrEmpty(queryString)) {
        return URL;
    }
    URL = URL.trim();
    if (URL.endsWith("?")) {
        result = URL + queryString;
    } else if (URL.contains("?")) {
        result = URL + "&" + queryString;
    } else {
        result = URL + "?" + queryString;
    }
    return result;
}