Java Code Examples for org.apache.commons.lang3.StringUtils#removeFirst()

The following examples show how to use org.apache.commons.lang3.StringUtils#removeFirst() . 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
Source File: ShadowSocksCrawlerService.java    From ShadowSocks-Share with Apache License 2.0 6 votes vote down vote up
/**
 * 图片解析
 */
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());
	}
}
 
Example 2
Source File: GtpCommand.java    From mylizzie with GNU General Public License v3.0 5 votes vote down vote up
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;
    }
}
 
Example 3
Source File: GtpCommand.java    From mylizzie with GNU General Public License v3.0 5 votes vote down vote up
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;
}
 
Example 4
Source File: WebDavServiceImpl.java    From studio with GNU General Public License v3.0 5 votes vote down vote up
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;
    }
}
 
Example 5
Source File: WebDavServiceImpl.java    From studio with GNU General Public License v3.0 5 votes vote down vote up
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);
    }
}
 
Example 6
Source File: GeneralUtils.java    From smockin with Apache License 2.0 4 votes vote down vote up
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;
    }
 
Example 7
Source File: RemoveFirst.java    From vscrawler with Apache License 2.0 4 votes vote down vote up
@Override
protected String handle(String input, String second) {
    return StringUtils.removeFirst(input, second);
}