當前位置: 首頁>>代碼示例>>Java>>正文


Java StringUtils.substringBeforeLast方法代碼示例

本文整理匯總了Java中org.apache.commons.lang3.StringUtils.substringBeforeLast方法的典型用法代碼示例。如果您正苦於以下問題:Java StringUtils.substringBeforeLast方法的具體用法?Java StringUtils.substringBeforeLast怎麽用?Java StringUtils.substringBeforeLast使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.lang3.StringUtils的用法示例。


在下文中一共展示了StringUtils.substringBeforeLast方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: formatArrayColumn

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
    * Format the column as an java.sqlArray
    * 
    * @param resultSet
    * @param columnIndex
    * @return
    * @throws SQLException
    * @throws IOException
    */
   private String formatArrayColumn(ResultSet resultSet, int columnIndex)
    throws SQLException, IOException {
Array array = resultSet.getArray(columnIndex);

Object[] objects = (Object[]) array.getArray();
String arrayStr = "{";
for (int i = 0; i < objects.length; i++) {
    arrayStr += objects[i] + ",";
}

if (arrayStr.contains(",")) {
    arrayStr = StringUtils.substringBeforeLast(arrayStr, ",");
}

arrayStr += "}";
return arrayStr;

/*
 * ArrayHttp arrayHttp = new ArrayHttp(array); ArrayTransporter
 * arrayTransporter = new ArrayTransporter(); String base64 =
 * arrayTransporter.toBase64(arrayHttp); return base64;
 */
   }
 
開發者ID:kawansoft,項目名稱:aceql-http,代碼行數:33,代碼來源:ResultSetWriter.java

示例2: doFilter

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
        ServletException {
    YiDuConstants.singleBookFlag.set(false);
    HttpServletRequest req = (HttpServletRequest) request;
    String uri = req.getRequestURI();
    if (StringUtils.endsWithAny(uri, "css", "js", "jpg", "png", "gif")) {
        // 靜態資源直接跳過
        logger.debug("ignore static resource." + uri);
        chain.doFilter(request, response);
    } else {
        // 非靜態資源時,根據具體的信息去做判別,時候需要標識單本
        String rootDomian = YiDuConstants.yiduConf.getString(YiDuConfig.ROOT_DOMAIN);
        String aname = StringUtils.substringBeforeLast(req.getServerName(), "." + rootDomian);
        logger.debug("aname : " + aname);
        if (StringUtils.isNotBlank(aname)) {
            int articleno = SingleBookManager.getArticleno(aname);
            if (articleno != 0) {
                // TODO 即便找到對應的小說,也隻做首頁和閱讀頁,其他全部404吧
                Pattern p = Pattern.compile(regex);
                Matcher m = p.matcher(uri);
                boolean matchFlag = false;
                String newURI = "";
                if (m.find()) {
                    // 閱讀頁
                    newURI = ReaderAction.URL + "?chapterno="
                            + StringUtils.substringBeforeLast(m.group(1), ".html");
                    matchFlag = true;
                } else if (StringUtils.equals(uri, "/") || StringUtils.isEmpty(uri)) {
                    // 首頁
                    newURI = InfoAction.URL + "?articleno=" + articleno;
                    matchFlag = true;
                } else {
                    // 返回404
                    YiDuConstants.singleBookFlag.set(true);
                    ((HttpServletResponse) response).sendError(HttpServletResponse.SC_NOT_FOUND);
                }
                logger.debug("newURI str: " + newURI);
                if (matchFlag) {
                    YiDuConstants.singleBookFlag.set(true);
                    YiDuConstants.singleBookServerName.set(req.getServerName());
                    req.getRequestDispatcher(newURI).forward(request, response);
                }
            } else {
                chain.doFilter(request, response);
            }
        } else {
            chain.doFilter(request, response);
        }
    }
}
 
開發者ID:luckyyeah,項目名稱:YiDu-Novel,代碼行數:52,代碼來源:SingleBookFilter.java

示例3: constructPatternId

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
public static String constructPatternId(String patternResourcePath, String patternsPath, String templateName, String jsonDataFileName) {
    final String patternPath = StringUtils.substringAfter(patternResourcePath, patternsPath + SLASH);
    final StringBuilder patternIdBuilder = new StringBuilder();
    if (StringUtils.endsWith(patternPath, HTML_EXT)) {
        patternIdBuilder.append(StringUtils.substringBeforeLast(patternPath, HTML_EXT));
    } else {
        patternIdBuilder.append(patternPath);
    }
    if (StringUtils.isNotBlank(templateName)) {
        patternIdBuilder.append(SLASH).append(templateName);
    }
    if (StringUtils.isNotBlank(jsonDataFileName)) {
        final String patternFileName = StringUtils.substringAfterLast(patternPath, SLASH);
        final String fileNameWithoutExt = StringUtils.substringBeforeLast(patternFileName, HTML_EXT);
        final String dataFileSuffix = StringUtils.substringBetween(jsonDataFileName, fileNameWithoutExt
                + SELECTOR, DATA_EXT);
        patternIdBuilder.append(SLASH).append(StringUtils.defaultString(dataFileSuffix, fileNameWithoutExt));
    }
    return StringUtils.replace(patternIdBuilder.toString(), SLASH, PATTERN_ID_REPLACEMENT);
}
 
開發者ID:deepthinkit,項目名稱:patternlab-for-sling,代碼行數:21,代碼來源:PatternLabUtils.java

示例4: parseRespond

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
 * 解析彈幕服務器接收到的協議數據
 * @param data
 * @return
 */
public Map<String, Object> parseRespond(String data){
	Map<String, Object> rtnMsg = new HashMap<String, Object>();
	
	//處理數據字符串末尾的'/0字符'
	data = StringUtils.substringBeforeLast(data, "/");
	
	//對數據字符串進行拆分
	String[] buff = data.split("/");
	
	//分析協議字段中的key和value值
	for(String tmp : buff){
		//獲取key值
		String key = StringUtils.substringBefore(tmp, "@=");
		//獲取對應的value值
		Object value = StringUtils.substringAfter(tmp, "@=");
		
		//如果value值中包含子序列化值,則進行遞歸分析
		if(StringUtils.contains((String)value, "@A")){
			value = ((String)value).replaceAll("@S", "/").replaceAll("@A", "@");
			value = this.parseRespond((String)value);
		}
		
		//將分析後的鍵值對添加到信息列表中
		rtnMsg.put(key, value);
	}
	
	return rtnMsg;
	
}
 
開發者ID:lslxy1021,項目名稱:DYB,代碼行數:35,代碼來源:MsgView.java

示例5: extract

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
public static File[] extract(File frame, Device userDevice) throws IOException {
    Mat colorFilterTextLow = new Mat(new double[] { 0, 2, 0 });
    Mat colorFilterNumberLow = new Mat(new double[] { 255, 255, 255 });
    final double threshText = 0.04d;
    final int threshTextSrcLow = 200;
    final int threshTextSrcUp = 255;

    final double threshNum = 0.06d;

    // iphone 7
    Mat colorFilterNumLow;
    Device device = userDevice != null ? userDevice : Device.ANDROID;
    switch (device) {
    case IPHONE:
        colorFilterNumLow = new Mat(new double[] { 25, 175, 50 });
        break;
    default:
        colorFilterNumLow = new Mat(new double[] { 25, 255, 50 });
        break;
    }

    Mat colorFilterNumUp = new Mat(new double[] { 50, 255, 255 });
    final int threshNumSrcLow = 180;
    final int threshNumSrcUp = 255;

    String prefix = StringUtils.substringBeforeLast(frame.getName(), "_");

    File text = process(frame, colorFilterTextLow, colorFilterNumberLow, threshText, threshTextSrcLow,
            threshTextSrcUp, CV_THRESH_BINARY, prefix + "_text");
    File number = process(frame, colorFilterNumLow, colorFilterNumUp, threshNum, threshNumSrcLow, threshNumSrcUp,
            CV_THRESH_BINARY_INV, prefix + "_num");

    colorFilterTextLow.close();
    colorFilterNumberLow.close();
    colorFilterNumLow.close();
    colorFilterNumUp.close();

    return new File[] { text, number };
}
 
開發者ID:BlackCraze,項目名稱:GameResourceBot,代碼行數:40,代碼來源:Preprocessor.java

示例6: PatternModel

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
public PatternModel(Resource resource, String patternsPath, String patternId, ResourceResolver resourceResolver) throws IOException {
    this.id = PatternLabUtils.constructPatternId(resource.getPath(), patternsPath);
    this.name = StringUtils.lowerCase(PatternLabUtils.getResourceTitleOrName(resource));
    this.template = StringUtils.EMPTY;
    this.path = resource.getPath();
    this.dataPath = StringUtils.EMPTY;
    this.displayed = StringUtils.isBlank(patternId) || StringUtils.startsWith(getId(), patternId);
    this.breadcrumb = Lists.newArrayList(new BreadcrumbItemModel(id, name));
    this.code = PatternLabUtils.getDataFromFile(path, resourceResolver);
    this.data = null;
    final String descriptionPath = StringUtils.substringBeforeLast(path, PatternLabConstants.SELECTOR) + PatternLabConstants.DESCRIPTION_EXT;
    this.description = PatternLabUtils.getDataFromFile(descriptionPath, resourceResolver);
    this.embeddedPatterns = Sets.newHashSet();
    this.includingPatterns = Sets.newHashSet();
}
 
開發者ID:deepthinkit,項目名稱:patternlab-for-sling,代碼行數:16,代碼來源:PatternModel.java

示例7: saveInTransaction

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
private CuratorTransaction saveInTransaction(CuratorTransaction transaction, byte[] data, String path) throws Exception {
    CuratorTransaction resultingTransaction = (transaction == null) ? getConnectedClientOrFailFast().inTransaction() : transaction;
    if (isNodeExistsInternal(path)) {
        resultingTransaction = resultingTransaction.setData().forPath(path, data).and();
    } else {
        String parentPath = StringUtils.substringBeforeLast(path, "/");
        if (!isNodeExistsInternal(parentPath)) {
            resultingTransaction = resultingTransaction.create().forPath(parentPath).and();
        }
        resultingTransaction = resultingTransaction.create().forPath(path, data).and();
    }
    return resultingTransaction;
}
 
開發者ID:Comcast,項目名稱:redirector,代碼行數:14,代碼來源:ZookeeperConnector.java

示例8: writeBackup

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
private void writeBackup(String path, final String addressIPV6, Action action, String weight) {
    int nameIndex = path.lastIndexOf(RedirectorConstants.DELIMETER);
    String stack = path.substring(basePath.length(), nameIndex);
    final String address = StringUtils.substringBeforeLast(StringUtils.substring(path, nameIndex + 1), IP_PORT_SEPARATOR);
    StackSnapshot currentSnapshot = createStackSnapshot(stack, address, addressIPV6, weight);
    if (action.getId().equals(Action.REGISTERED.getId())) {
        discoveryStacksBackupManager.addStackSnapshot(currentSnapshot);
    } else {
        discoveryStacksBackupManager.deleteStackSnapshot(currentSnapshot);
    }
}
 
開發者ID:Comcast,項目名稱:redirector,代碼行數:12,代碼來源:CustomServiceCache.java

示例9: getResource

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
@Override
public final Resource getResource(String pathInContext) {
	ServletContextHandler.Context context = (ServletContextHandler.Context) getServletContext();
	ServletContextHandler contextHandler = (ServletContextHandler) context.getContextHandler();
	
	for (ServletMapping mapping: contextHandler.getServletHandler().getServletMappings()) {
		if (mapping.getServletName().equals(getServletName())) {
			for (String pathSpec: mapping.getPathSpecs()) {
				String relativePath = null;
				if (pathSpec.endsWith("/*")) {
					pathSpec = StringUtils.substringBeforeLast(pathSpec, "/*");
					if (pathInContext.startsWith(pathSpec + "/")) 
						relativePath = pathInContext.substring(pathSpec.length());
				} else if (pathSpec.startsWith("*.")) {
					pathSpec = StringUtils.stripStart(pathSpec, "*");
					if (pathInContext.endsWith(pathSpec))
						relativePath = pathInContext;
				} else if (pathSpec.equals(pathInContext)) {
					relativePath = pathInContext;
				}
				if (relativePath != null) {
					relativePath = StringUtils.stripStart(relativePath, "/");
					Resource resource = Resource.newResource(loadResource(relativePath));
					if (resource != null && resource.exists())
						return resource;
				}
			}
		}
	}
	
	return null;
}
 
開發者ID:jmfgdev,項目名稱:gitplex-mit,代碼行數:33,代碼來源:AssetServlet.java

示例10: getIPv4

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
private String getIPv4(String path) {
    int nameIndex = path.lastIndexOf(RedirectorConstants.DELIMETER);
    return StringUtils.substringBeforeLast(StringUtils.substring(path, nameIndex + 1), IP_PORT_SEPARATOR);
}
 
開發者ID:Comcast,項目名稱:redirector,代碼行數:5,代碼來源:CustomServiceCache.java

示例11: ShowQrcodeRequest

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
    * 構造函數
    * @param ticket 獲取的二維碼ticket,憑借此ticket可以在有效時間內換取二維碼
    * @param fullDownPath  下載文件路徑+文件名
    */
   public ShowQrcodeRequest(String ticket, String fullDownPath) {
	this.ticket = ticket;
	this.fileName = StringUtils.substringAfterLast(fullDownPath, File.separator);
       this.filePath = StringUtils.substringBeforeLast(fullDownPath, File.separator) + File.separator;
}
 
開發者ID:rocye,項目名稱:wx-idk,代碼行數:11,代碼來源:ShowQrcodeRequest.java

示例12: PerpetualMediaGetRequest

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
 * 構造器
 * @param mediaId  		媒體文件ID
 * @param fullDownPath  下載文件路徑+文件名
 */
public PerpetualMediaGetRequest(String mediaId, String fullDownPath) {
    this.media_id = mediaId;
    this.fileName = StringUtils.substringAfterLast(fullDownPath, File.separator);
    this.filePath = StringUtils.substringBeforeLast(fullDownPath, File.separator) + File.separator;
}
 
開發者ID:rocye,項目名稱:wx-idk,代碼行數:11,代碼來源:PerpetualMediaGetRequest.java

示例13: NewsInnerImgAddRequest

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
 * 構造器
 * @param fullFilePath  媒體文件路徑+文件名
 */
public NewsInnerImgAddRequest(String fullFilePath) {
    this.fileName = StringUtils.substringAfterLast(fullFilePath, File.separator);
    this.filePath = StringUtils.substringBeforeLast(fullFilePath, File.separator) + File.separator;
}
 
開發者ID:rocye,項目名稱:wx-idk,代碼行數:9,代碼來源:NewsInnerImgAddRequest.java

示例14: TempMaterialGetRequest

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
 * 構造器
 * @param mediaId  		媒體文件ID
 * @param fullDownPath  下載文件路徑+文件名
 */
public TempMaterialGetRequest(String mediaId, String fullDownPath) {
    this.media_id = mediaId;
    this.fileName = StringUtils.substringAfterLast(fullDownPath, File.separator);
    this.filePath = StringUtils.substringBeforeLast(fullDownPath, File.separator) + File.separator;
}
 
開發者ID:rocye,項目名稱:wx-idk,代碼行數:11,代碼來源:TempMaterialGetRequest.java

示例15: TempMaterialAddRequest

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
 * 構造器
 * @param type          媒體文件類型,分別有圖片image、語音voice、視頻video和縮略圖thumb
 * @param fullFilePath  媒體文件路徑+文件名
 */
public TempMaterialAddRequest(String type, String fullFilePath) {
    this.type = type;
    this.fileName = StringUtils.substringAfterLast(fullFilePath, File.separator);
    this.filePath = StringUtils.substringBeforeLast(fullFilePath, File.separator) + File.separator;
}
 
開發者ID:rocye,項目名稱:wx-idk,代碼行數:11,代碼來源:TempMaterialAddRequest.java


注:本文中的org.apache.commons.lang3.StringUtils.substringBeforeLast方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。