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

The following examples show how to use java.net.URL#endsWith() . These examples are extracted from open source projects. 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
/**
 * 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
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
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;
}