本文整理汇总了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;
*/
}
示例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);
}
}
}
示例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);
}
示例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;
}
示例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 };
}
示例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();
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}