List of usage examples for org.apache.commons.lang StringUtils substringBetween
public static String substringBetween(String str, String open, String close)
Gets the String that is nested in between two Strings.
From source file:com.zb.app.biz.service.WeixinTest.java
private boolean _compareFakeid(String fakeid, String openid) { String _url = "http://mp.weixin.qq.com/cgi-bin/singlesendpage?t=message/send&action=index&token=" + token + "&tofakeid=" + fakeid + "&lang=zh_CN"; GetMethod get = new GetMethod(_url); get.setRequestHeader("Cookie", this.cookiestr); get.setRequestHeader("Host", "mp.weixin.qq.com"); get.setRequestHeader("Referer", "https://mp.weixin.qq.com/cgi-bin/contactmanage?t=user/index&pagesize=10&pageidx=0&type=0&groupid=0&token=" + token + "&lang=zh_CN"); get.setRequestHeader("Content-Type", "text/html;charset=UTF-8"); try {/*from w w w . jav a 2 s . co m*/ int code = httpClient.executeMethod(get); if (HttpStatus.SC_OK == code) { String str = get.getResponseBodyAsString(); String msgJson = StringUtils.substringBetween(str, "{\"msg_item\":", "}};"); JSONParser parser = new JSONParser(); try { JSONArray array = (JSONArray) parser.parse(msgJson); for (int i = 0; i < array.size(); i++) { JSONObject obj = (JSONObject) array.get(i); String content = (String) obj.get("content"); if (content.contains(openid)) { return true; } } } catch (Exception e) { // log.error(e.getMessage(), e); } } } catch (Exception e) { // log.error(e.getMessage(), e); } return false; }
From source file:hydrograph.ui.common.property.util.Utils.java
/** * * checking the parameter in paramsMap//from w w w . j a v a 2 s . c om * @param value * @return value of Parameter if found in Map otherwise Parameter not found */ public String getParamValue(String value) { Optional<String> optional = Optional.of(value); if (jobProps != null && !jobProps.isEmpty() && optional.isPresent() && value.contains("@{")) { String param = ""; String[] splitString = value.split("/"); for (String field : splitString) { if (field.startsWith("@{")) { field = StringUtils.substringBetween(field, "@{", "}"); for (Map.Entry<String, String> entry : paramsMap.entrySet()) { if (StringUtils.equals(entry.getKey(), field)) { if (entry.getValue().endsWith("/")) { param = param == null ? entry.getValue() : param.concat(entry.getValue() + "/"); } param = param == null ? entry.getValue() : param.concat(entry.getValue() + "/"); } } } else { param += field + "/"; } } return getResult(param); } return PARAMETER_NOT_FOUND; }
From source file:com.hmsinc.epicenter.surveillance.notification.MailingEventNotifierTest.java
private String getTextMessageContent() throws IOException, MessagingException { String content = loadContent(getMessageAsStream()); String prefix = "Content-Type: text/plain; charset=UTF-8Content-Transfer-Encoding: 7bit"; String suffix = "------=_Part"; String rtn = StringUtils.substringBetween(content, prefix, suffix); return rtn;//from ww w. ja v a 2s . co m }
From source file:com.hmsinc.epicenter.surveillance.notification.MailingEventNotifierTest.java
private String getHtmlMessageContent() throws IOException, MessagingException { String content = loadContent(getMessageAsStream()); String prefix = "Content-Type: text/html;charset=UTF-8Content-Transfer-Encoding: 7bit"; String suffix = "------=_Part"; String rtn = StringUtils.substringBetween(content, prefix, suffix); return rtn;//from w w w.j ava 2 s .c o m }
From source file:com.pr7.logging.CustomDailyRollingFileAppender.java
public void setArchiveMaxDays(String archiveMaxDays) { String jndiKey = StringUtils.substringBetween(archiveMaxDays, "{", "}"); this.archiveMaxDays = PropertyHelper.getProperty(jndiName, jndiKey); if (this.archiveMaxDays == null) { this.archiveMaxDays = "30"; }//from w w w .java 2 s.c om System.out.println("archiveMaxDays = " + this.archiveMaxDays); }
From source file:com.qualogy.qafe.gwt.server.event.assembler.AbstractEventRenderer.java
private void fillBuiltInComponentGVO(BuiltInComponentGVO builtInComponentGVO, String string) { String componentIdInComponentData = StringUtils.substringBefore(string, "["); String componentAttributesInComponentData = StringUtils.substringBetween(string, "[", "]"); String[] componentAttributes = StringUtils.split(componentAttributesInComponentData, ","); List<String> attributes = new ArrayList<String>(); for (int k = 0; componentAttributes != null && k < componentAttributes.length; k++) { attributes.add(componentAttributes[k]); }/*w ww. jav a 2 s . co m*/ builtInComponentGVO.setAttributes(attributes); builtInComponentGVO.setComponentId(componentIdInComponentData); }
From source file:com.pr7.logging.CustomDailyRollingFileAppender.java
public void setArchiveCompress(String archiveCompress) { String jndiKey = StringUtils.substringBetween(archiveCompress, "{", "}"); this.archiveCompress = PropertyHelper.getProperty(jndiName, jndiKey); if (this.archiveCompress == null) { this.archiveCompress = "true"; }/*from ww w . j a v a 2s . co m*/ System.out.println("archiveCompress = " + this.archiveCompress); }
From source file:com.pr7.logging.CustomDailyRollingFileAppender.java
public void setArchiveTiming(String archiveTiming) { String jndiKey = StringUtils.substringBetween(archiveTiming, "{", "}"); this.archiveTiming = PropertyHelper.getProperty(jndiName, jndiKey); if (this.archiveTiming == null) { this.archiveTiming = "07:00:00"; }//w ww. j ava2 s.c o m System.out.println("archiveTiming = " + this.archiveTiming); }
From source file:io.ecarf.core.utils.LogParser.java
/** * - Processing file: /tmp/wordnet_links.nt.gz.kryo.gz, dictionary items: 49382611, memory usage: 14.336268931627274GB, timer: 290.0 ms * /tmp/wikipedia_links_en.nt.gz.kryo.gz, dictionary items: 44, memory usage: 0.013648882508277893GB, timer: 2.636 s * START: Downloading file: interlanguage_links_chapters_en.nt.gz.kryo.gz, memory usage: 0.0GB * @param line//from w w w . ja va 2 s.com * @param after * @return */ private double[] extractAndGetMemoryDictionaryItems(String line) { double memory = 0; double items = 0; String memoryStr = null; if (line.contains(TIMER_PREFIX)) { memoryStr = StringUtils.substringBetween(line, MEM_USE, TIMER_PREFIX); if (line.contains(DIC_ITEMS)) { String itemsStr = StringUtils.trim(StringUtils.substringBetween(line, DIC_ITEMS, MEM_USE)); items = Double.parseDouble(itemsStr); } } else { memoryStr = StringUtils.substringAfter(line, MEM_USE); } if (memoryStr != null) { memoryStr = StringUtils.remove(memoryStr, "GB"); memoryStr = StringUtils.strip(memoryStr); } memory = Double.parseDouble(memoryStr); double[] values = new double[] { memory, items }; return values; }
From source file:bbcdataservice.BBCDataService.java
private ArrayList<Channel> getRegionChannels(final String channelId, final String channelName, final String webSite, final int category, final ProgressMonitor progress) { final ArrayList<Channel> channels = new ArrayList<Channel>(); try {// w w w. ja v a 2s . co m File regionsFile = new File(mWorkingDir, "regions"); IOUtilities.download(new URL(PROGRAMMES_URL + webSite), regionsFile); StreamUtilities.bufferedReader(regionsFile, new BufferedReaderProcessor() { public void process(BufferedReader reader) throws IOException { String line; while ((line = reader.readLine()) != null) { if (line.contains(webSite)) { line = StringUtils.substringAfter(line, "a href"); String regionId = StringUtils.substringBetween(line, "schedules/", "\""); if ("today".equalsIgnoreCase(regionId) || "tomorrow".equalsIgnoreCase(regionId) || "yesterday".equalsIgnoreCase(regionId)) { continue; } if (StringUtils.isNotEmpty(regionId) && !regionId.contains("/")) { String regionName = StringUtils.substringBetween(line, ">", "</a"); regionName = HTMLTextHelper.convertHtmlToText(regionName); if ("Schedule".equalsIgnoreCase(regionName) || "View full schedule".equalsIgnoreCase(regionName)) { continue; } String webSite = StringUtils.substringBetween(line, "=\"", "\""); boolean found = false; for (Channel channel : channels) { if (channel.getWebpage().equalsIgnoreCase(PROGRAMMES_URL + webSite)) { found = true; break; } } if (!found) { String localName = channelName + " (" + regionName + ")"; String localId = channelId + "." + regionId; if (StringUtils.isNotEmpty(localName) && StringUtils.isNotEmpty(localId)) { progress.setMessage( mLocalizer.msg("search.channel", "Found channel: {0}", localName)); Channel channel = new Channel(BBCDataService.this, localName, localId, TIME_ZONE, COUNTRY, COPYRIGHT, PROGRAMMES_URL + webSite, CHANNEL_GROUP, null, category); channels.add(channel); } } } } } } }); regionsFile.delete(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return channels; }