下面列出了org.apache.commons.lang3.StringUtils#removeFirst ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* 图片解析
*/
protected ShadowSocksDetailsEntity parseImg(String imgURL) throws IOException, NotFoundException {
String str = StringUtils.removeFirst(imgURL, "data:image/png;base64,");
Map<DecodeHintType, Object> hints = new LinkedHashMap<>();
// 解码设置编码方式为:utf-8,
hints.put(DecodeHintType.CHARACTER_SET, StandardCharsets.UTF_8.name());
//优化精度
hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
//复杂模式,开启PURE_BARCODE模式
hints.put(DecodeHintType.PURE_BARCODE, Boolean.TRUE);
try (ByteArrayInputStream bis = new ByteArrayInputStream(Base64.decodeBase64(str))) {
BufferedImage image = ImageIO.read(bis);
Binarizer binarizer = new HybridBinarizer(new BufferedImageLuminanceSource(image));
BinaryBitmap binaryBitmap = new BinaryBitmap(binarizer);
Result res = new MultiFormatReader().decode(binaryBitmap, hints);
return parseLink(res.toString());
}
}
static String getLineWithoutResponseHeader(List<String> response, int lineIndex) {
if (lineIndex < 0 || lineIndex >= (response == null ? -1 : response.size())) {
return "";
}
String line = StringUtils.defaultString(response.get(lineIndex));
if (lineIndex == 0) {
return StringUtils.removeFirst(line, "^[=?]\\d*\\s*");
} else {
return line;
}
}
static List<String> removeResponseHeaderInPlace(List<String> response) {
if (CollectionUtils.isNotEmpty(response)) {
String beginElement = response.get(0);
if (beginElement.startsWith("=") || beginElement.startsWith("?")) {
beginElement = StringUtils.removeFirst(beginElement, "^[=?]\\d*\\s*");
response.set(0, beginElement);
}
}
return response;
}
protected String getUrl(DavResource resource, String baseUrl, String deliveryUrl, String basePath) {
String relativePath = StringUtils.removeFirst(resource.getPath(), basePath);
if(resource.isDirectory()) {
return baseUrl + relativePath;
} else {
return (StringUtils.isNotEmpty(deliveryUrl)? deliveryUrl : baseUrl) + relativePath;
}
}
protected String getUrl(DavResource resource, String profileId, WebDavProfile profile) {
String relativePath = StringUtils.removeFirst(resource.getPath(), URI.create(profile.getBaseUrl()).getPath());
if(resource.isDirectory()) {
return relativePath;
} else {
return getRemoteAssetUrl(profileId, relativePath);
}
}
public static String sanitizeMultiUserPath(final UserModeEnum usermode, final String pathInfo, final String ctxPath) {
return ( UserModeEnum.ACTIVE.equals(usermode) && StringUtils.isNotBlank(ctxPath) )
? StringUtils.removeFirst(pathInfo, ctxPath)
: pathInfo;
}
@Override
protected String handle(String input, String second) {
return StringUtils.removeFirst(input, second);
}