本文整理匯總了Java中org.apache.commons.lang.StringUtils.substringAfter方法的典型用法代碼示例。如果您正苦於以下問題:Java StringUtils.substringAfter方法的具體用法?Java StringUtils.substringAfter怎麽用?Java StringUtils.substringAfter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.lang.StringUtils
的用法示例。
在下文中一共展示了StringUtils.substringAfter方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: subByteArrays
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
public byte[] subByteArrays(byte[] data,byte[] startArray)
{
if(data==null||data.length<=0)
{
System.out.println("data參數錯誤!");
return null;
}
String[] dataHex=byteArrayToHexArray(data);//轉換為hex字符數組
String dataHexStr=Arrays.toString(dataHex);//轉換為hex字符串
dataHexStr=StringUtils.substringBetween(dataHexStr, "[", "]").replaceAll("\\s", "");//去括號空格
String[] startHex=byteArrayToHexArray(startArray);//轉換為hex字符數組
String startHexStr=Arrays.toString(startHex);//轉換為hex字符串
startHexStr=StringUtils.substringBetween(startHexStr, "[", "]").replaceAll("\\s", "");//去括號空格
String resultHex=StringUtils.substringAfter(dataHexStr, startHexStr);//截取並轉換為hex字符串
if(resultHex==null)
{
//System.out.println("注意:截取內容為空,無數據!");
return null;
}
String[] result=StringUtils.split(resultHex, ',');//重組為hexstr數組
// System.out.println(Arrays.toString(result));
return hexArrayToBtyeArray(result);
}
示例2: getColumnLengthAndPrecision
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
public static int[] getColumnLengthAndPrecision(Column column){
int[] ret = new int[2];
String data = StringUtils.substringBetween(column.getMysqlType(), "(",")");
String length = StringUtils.substringBefore(data, ",");
String precision = StringUtils.substringAfter(data, ",");
String type = getColumnType(column).toUpperCase();
if("SET".equals(type) || "ENUM".equals(type)){
ret[0] = 0;
ret[1] = 0;
}else{
if(StringUtils.isEmpty(length)){
ret[0] = 0;
}else{
ret[0] = Integer.parseInt(length);
}
if(StringUtils.isEmpty(precision)){
ret[1] = 0;
}else{
ret[1] = Integer.parseInt(precision);
}
}
return ret;
}
示例3: doDelete
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String endpoint = StringUtils.substringAfter(req.getPathInfo(), "/clients/");
if (StringUtils.isEmpty(endpoint)) {
resp.sendError(HttpServletResponse.SC_BAD_REQUEST);
return;
}
LOG.debug("Removing security info for end-point {}", endpoint);
if (this.store.remove(endpoint) != null) {
resp.sendError(HttpServletResponse.SC_OK);
} else {
resp.sendError(HttpServletResponse.SC_NOT_FOUND);
}
}
示例4: subByteArray
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
* 截取目標字節數組中startArray後麵的字節數組
* @param byteArray
* @param startArray
* @return
*/
public byte[] subByteArray(byte[] byteArray,byte[] startArray)
{
if(byteArray==null||byteArray.length<=0)
{
System.out.println("data參數錯誤!");
return null;
}
String[] dataHex=toHexArray(byteArray);//轉換為hex字符數組
String dataHexStr=Arrays.toString(dataHex);//轉換為hex字符串
dataHexStr=StringUtils.substringBetween(dataHexStr, "[", "]").replaceAll("\\s", "");//去括號空格
String[] startHex=toHexArray(startArray);//轉換為hex字符數組
String startHexStr=Arrays.toString(startHex);//轉換為hex字符串
startHexStr=StringUtils.substringBetween(startHexStr, "[", "]").replaceAll("\\s", "");//去括號空格
String resultHex=StringUtils.substringAfter(dataHexStr, startHexStr);//截取並轉換為hex字符串
if(resultHex==null)
{
//System.out.println("注意:截取內容為空,無數據!");
return null;
}
String[] result=StringUtils.split(resultHex, ',');//重組為hexstr數組
// System.out.println(Arrays.toString(result));
return toBtyeArray(result);
}
示例5: SubHexArraysByStr
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
* 截取以什麽開頭的數據
* @param data
* @param startHexStr
* @return
* @throws UnsupportedEncodingException
*/
public String[] SubHexArraysByStr(byte[] data,String startStr) throws UnsupportedEncodingException
{
if(data==null||data.length<=0)
{
System.out.println("data數據無效!");
return null;
}
String[] result=null;
//轉換原數據
String[] hexarray=byteArrayToHexArray(data);
String hexstr=Arrays.toString(hexarray);
hexstr=StringUtils.substringBetween(hexstr, "[", "]").replaceAll("\\s", "");//原數據字符串去括號空格
////轉換匹配參數數據
byte[] startArray=startStr.getBytes("utf-8");//轉換為字節
String[] startHex=byteArrayToHexArray(startArray);//轉換為hex字符數組
String startHexStr=Arrays.toString(startHex);//轉換為hex字符串
startHexStr=StringUtils.substringBetween(startHexStr, "[", "]").replaceAll("\\s", "");//去括號空格
String resultHex=StringUtils.substringAfter(hexstr, startHexStr);
if(resultHex==null)
{
//System.out.println("注意:截取內容為空,無數據!");
return null;
}
result=StringUtils.split(resultHex, ',');//重組為hexstr數組
return result;
}
示例6: getServicePortPID
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
* This function will be return process ID which running on defined port.
*
* @return the service port pid
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public String getServicePortPID(Properties properties) throws IOException {
int portNumber = Integer.parseInt(properties.getProperty(EXECUTION_TRACKING_PORT));
if (OSValidator.isWindows()) {
ProcessBuilder builder = new ProcessBuilder(new String[] { "cmd",
"/c", "netstat -a -o -n |findstr :" + portNumber });
Process process = builder.start();
InputStream inputStream = process.getInputStream();
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(inputStream));
String str = bufferedReader.readLine();
str = StringUtils.substringAfter(str, "LISTENING");
str = StringUtils.trim(str);
return str;
}
return "";
}
示例7: getRootElementName
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
private String getRootElementName(String rowTag) {
String rootElementName = null;
if (StringUtils.isBlank(rowTag) || !rowTag.startsWith("/")) {
return null;
}
// TODO: Ask for requirement how row tag will be come
if (rowTag.startsWith("/")) {
rootElementName = StringUtils.substringBetween(rowTag, "/", "/");
}
if (StringUtils.isBlank(rootElementName)) {
rootElementName = StringUtils.substringAfter(rowTag, "/");
}
return rootElementName;
}
示例8: render
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
* 直接輸出內容的簡便函數.
* eg.
* render("text/plain", "hello", "encoding:GBK");
* render("text/plain", "hello", "no-cache:false");
* render("text/plain", "hello", "encoding:GBK", "no-cache:false");
*
* @param headers 可變的header數組,目前接受的值為"encoding:"或"no-cache:",默認值分別為UTF-8和true.
*/
public static void render(final HttpServletResponse response,final String contentType, final String content, final String... headers) {
try {
//分析headers參數
String encoding = ENCODING_DEFAULT;
boolean noCache = NOCACHE_DEFAULT;
for (String header : headers) {
String headerName = StringUtils.substringBefore(header, ":");
String headerValue = StringUtils.substringAfter(header, ":");
if (StringUtils.equalsIgnoreCase(headerName, ENCODING_PREFIX)) {
encoding = headerValue;
} else if (StringUtils.equalsIgnoreCase(headerName, NOCACHE_PREFIX)) {
noCache = Boolean.parseBoolean(headerValue);
} else
throw new IllegalArgumentException(headerName + "不是一個合法的header類型");
}
//設置headers參數
String fullContentType = contentType + ";charset=" + encoding;
response.setContentType(fullContentType);
if (noCache) {
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
}
PrintWriter writer = response.getWriter();
writer.write(content);
writer.flush();
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
示例9: doFilter
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
String contextPath = ((HttpServletRequest) request).getContextPath();
String requestURI = httpRequest.getRequestURI();
requestURI = StringUtils.substringAfter(requestURI, contextPath);
if (StringUtils.equals("/", requestURI)) {
requestURI = "/index.html";
}
String newURI = "/dist" + requestURI;
request.getRequestDispatcher(newURI).forward(request, response);
}
示例10: addTableRegex
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
public void addTableRegex(String tableRegex){
String[] tableRegexs = StringUtils.split(tableRegex, ",");
for(String regex : tableRegexs){
String localTbl = StringUtils.substringBefore(regex.trim(), ".");
String partitionTblRegex = StringUtils.substringAfter(regex.trim(), ".");
map.put(localTbl, partitionTblRegex);
}
}
示例11: getChild
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
@Override
public Resource getChild(String relPath) {
if (StringUtils.contains(relPath, '/')) {
String firstPart = StringUtils.substringBefore(relPath, "/");
String rest = StringUtils.substringAfter(relPath, "/");
if (children.containsKey(firstPart)) {
return children.get(firstPart).getChild(rest);
}
} else if (children.containsKey(relPath)) {
return children.get(relPath);
}
return null;
}
示例12: getServicePortPID
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
* This function will be return process ID which running on defined port
*
*/
public String getServicePortPID(String portNumber) throws IOException{
if(OSValidator.isWindows()){
ProcessBuilder builder = new ProcessBuilder(new String[]{"cmd", "/c" ,"netstat -a -o -n |findstr :"+portNumber});
Process process =builder.start();
InputStream inputStream = process.getInputStream();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
String str = bufferedReader.readLine();
str=StringUtils.substringAfter(str, "LISTENING");
str=StringUtils.trim(str);
return str;
}
return "";
}
示例13: getProperties
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
private static Properties getProperties(String conf) throws IOException {
Properties properties = new Properties();
if (conf.startsWith(CLASSPATH_URL_PREFIX)) {
conf = StringUtils.substringAfter(conf, CLASSPATH_URL_PREFIX);
properties.load(TotoroLauncher.class.getClassLoader().getResourceAsStream(conf));
} else {
properties.load(new FileInputStream(conf));
}
return properties;
}
示例14: subHexArray
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
* 截取以文本開頭的字節數據並以hexStringArray數組返回
* @param data 目標字節數組
* @param startHexStr 普通文本,默認以utf8形式
* @return
* @throws UnsupportedEncodingException
*/
public String[] subHexArray(byte[] data,String startStr) throws UnsupportedEncodingException
{
if(data==null||data.length<=0)
{
System.out.println("data數據無效!");
return null;
}
String[] result=null;
//轉換原數據
String[] hexarray=toHexArray(data);
String hexstr=Arrays.toString(hexarray);
hexstr=StringUtils.substringBetween(hexstr, "[", "]").replaceAll("\\s", "");//原數據字符串去括號空格
////轉換匹配參數數據
byte[] startArray=startStr.getBytes("utf-8");//轉換為字節
String[] startHex=toHexArray(startArray);//轉換為hex字符數組
String startHexStr=Arrays.toString(startHex);//轉換為hex字符串
startHexStr=StringUtils.substringBetween(startHexStr, "[", "]").replaceAll("\\s", "");//去括號空格
String resultHex=StringUtils.substringAfter(hexstr, startHexStr);
if(resultHex==null)
{
//System.out.println("注意:截取內容為空,無數據!");
return null;
}
result=StringUtils.split(resultHex, ',');//重組為hexstr數組
return result;
}
示例15: initResponseHeader
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
* 分析並設置contentType與headers.
*/
private static HttpServletResponse initResponseHeader(final String contentType, final String... headers) {
//分析headers參數
String encoding = DEFAULT_ENCODING;
boolean noCache = DEFAULT_NOCACHE;
for (String header : headers) {
String headerName = StringUtils.substringBefore(header, ":");
String headerValue = StringUtils.substringAfter(header, ":");
if (StringUtils.equalsIgnoreCase(headerName, HEADER_ENCODING)) {
encoding = headerValue;
} else if (StringUtils.equalsIgnoreCase(headerName, HEADER_NOCACHE)) {
noCache = Boolean.parseBoolean(headerValue);
} else {
throw new IllegalArgumentException(headerName + "不是一個合法的header類型");
}
}
HttpServletResponse response = ServletActionContext.getResponse();
//設置headers參數
String fullContentType = contentType + ";charset=" + encoding;
response.setContentType(fullContentType);
if (noCache) {
ServletUtils.setDisableCacheHeader(response);
}
return response;
}