java.net.URL#endsWith ( )源码实例Demo

下面列出了java.net.URL#endsWith ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

/**
 * 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;
}
 
源代码2 项目: AOSPBrowserInstaller   文件: Downloader.java
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();
    }
}
 
源代码3 项目: cerberus-source   文件: StringUtil.java
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;
}