當前位置: 首頁>>代碼示例>>Java>>正文


Java StringUtils.removeStart方法代碼示例

本文整理匯總了Java中org.apache.commons.lang.StringUtils.removeStart方法的典型用法代碼示例。如果您正苦於以下問題:Java StringUtils.removeStart方法的具體用法?Java StringUtils.removeStart怎麽用?Java StringUtils.removeStart使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.lang.StringUtils的用法示例。


在下文中一共展示了StringUtils.removeStart方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: closeEditorIfAlreadyOpen

import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
private boolean closeEditorIfAlreadyOpen(IPath jobFilePath, String fileName) {

		String jobPathRelative = StringUtils.removeStart(jobFilePath.toString(), "..");
		jobPathRelative = StringUtils.removeStart(jobPathRelative, "/");
		String jobPathAbsolute = StringUtils.replace(jobPathRelative, "/", "\\");
		IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
		if (activeWorkbenchWindow != null) {
			IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
			for (IEditorReference editorRefrence : activePage.getEditorReferences()) {
				if (StringUtils.equals(editorRefrence.getTitleToolTip(), jobPathRelative)
						|| StringUtils.equals(editorRefrence.getTitleToolTip(), jobPathAbsolute)
						|| fileName.equals(editorRefrence.getTitleToolTip())) {
					IEditorPart editor = editorRefrence.getEditor(true);
					if (!activePage.closeEditor(editor, true)) {
						LOGGER.debug("Editor not closed");
					}
					LOGGER.debug("Editor closed");
					return true;
				}
			}
		}
		return false;
	}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:24,代碼來源:ExternalSchemaUpdaterHandler.java

示例2: locateExactMatchingTarget

import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
private CommandTarget locateExactMatchingTarget(final String userInput)// exact matching
    throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
  CommandTarget commandTarget = null;

  Map<String, CommandTarget> commandTargetsMap = commandManager.getCommands();
  // Reverse sort the command names because we should start from longer names
  // E.g. Consider commands "A", "A B" & user input as "A B --opt1=val1"
  // In this case, "A B" is the most probable match & should be matched first
  // which can be achieved by reversing natural order of sorting.
  Set<String> commandNamesReverseSorted = new TreeSet<String>(Collections.reverseOrder());
  commandNamesReverseSorted.addAll(commandTargetsMap.keySet());

  // Now we need to locate the CommandTargets from the entries in the map
  for (final String commandName : commandNamesReverseSorted) {
    if (userInput.startsWith(commandName) && commandWordsMatch(userInput, commandName)) {
      // This means that the user has entered the command & name matches exactly
      commandTarget = commandTargetsMap.get(commandName);
      if (commandTarget != null) {
        String remainingBuffer = StringUtils.removeStart(userInput, commandName);
        commandTarget = commandTarget.duplicate(commandName, remainingBuffer);
        break;
      }
    }
  }
  return commandTarget;
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:27,代碼來源:GfshParser.java

示例3: getOriginalBeanName

import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
 * 獲取bean name的原始名稱,如果是代理的bean,返回原始bean name。
 *
 * @param beanName
 * @return
 */
public static String getOriginalBeanName(String beanName) {
    if (beanName.startsWith(TARGET_NAME_PREFIX)) {
        return StringUtils.removeStart(beanName, TARGET_NAME_PREFIX);
    } else {
        return beanName;
    }
}
 
開發者ID:zouzhirong,項目名稱:configx,代碼行數:14,代碼來源:ProxyUtils.java

示例4: doPut

import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    String[] path = StringUtils.split(req.getPathInfo(), '/');
    String clientEndpoint = path[0];

    // at least /endpoint/objectId/instanceId
    if (path.length < 3) {
        resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Invalid path");
        return;
    }

    try {
        String target = StringUtils.removeStart(req.getPathInfo(), "/" + clientEndpoint);
        Registration registration = server.getRegistrationService().getByEndpoint(clientEndpoint);
        if (registration != null) {
            // get content format
            String contentFormatParam = req.getParameter(FORMAT_PARAM);
            ContentFormat contentFormat = contentFormatParam != null
                    ? ContentFormat.fromName(contentFormatParam.toUpperCase()) : null;

            // create & process request
            LwM2mNode node = extractLwM2mNode(target, req);
            WriteRequest request = new WriteRequest(Mode.REPLACE, contentFormat, target, node);
            WriteResponse cResponse = server.send(registration, request, TIMEOUT);
            processDeviceResponse(req, resp, cResponse);
        } else {
            resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
            resp.getWriter().format("No registered client with id '%s'", clientEndpoint).flush();
        }
    } catch (RuntimeException | InterruptedException e) {
        handleException(e, resp);
    }
}
 
開發者ID:IoTKETI,項目名稱:IPE-LWM2M,代碼行數:37,代碼來源:ClientServlet.java

示例5: copyJarResourcesRecursively

import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
public static boolean copyJarResourcesRecursively(
        final File destDir, final JarURLConnection jarConnection
) throws IOException {

    final JarFile jarFile = jarConnection.getJarFile();

    for (final Enumeration<JarEntry> e = jarFile.entries(); e.hasMoreElements(); ) {
        final JarEntry entry = e.nextElement();
        if (entry.getName().startsWith(jarConnection.getEntryName())) {
            final String filename = StringUtils.removeStart(
                    entry.getName(), //
                    jarConnection.getEntryName());

            final File f = new File(destDir, filename);
            if (!entry.isDirectory()) {
                final InputStream entryInputStream = jarFile.getInputStream(entry);
                if (!FileUtils.copyStream(entryInputStream, f)) {
                    return false;
                }
                entryInputStream.close();
            } else {
                if (!FileUtils.ensureDirectoryExists(f)) {
                    throw new IOException("Could not create directory: " + f.getAbsolutePath());
                }
            }
        }
    }
    return true;
}
 
開發者ID:airsonic,項目名稱:airsonic,代碼行數:30,代碼來源:FileUtils.java

示例6: getSonArrays

import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
 * 根據字節數組拆分若幹個字字節數組
 * @param data    待拆分數組
 * @param separator 分割數組
 * @return 
 */
public byte[][] getSonArrays(byte[] data,byte[] separator)
{
	if(data==null||data.length<=0||separator==null||separator.length<=0)
	{
		System.out.println("data||separator數據無效!");
		return null;
	}
	String[] dataHexArray=toHexArray(data);
	String dataHexStr=StringUtils.substringBetween(Arrays.toString(dataHexArray), "[", "]").replaceAll("\\s","");
	//System.out.println("待拆分字符串:"+dataHexStr);
	String[] separatorHexhArray=toHexArray(separator);
	String separatorHexStr=StringUtils.substringBetween(Arrays.toString(separatorHexhArray), "[", "]").replaceAll("\\s","");
	//System.out.println("字符串拆分符:"+separatorHexStr);
	//得到拆分後的數組
	String[] arrays=StringUtils.splitByWholeSeparator(dataHexStr, separatorHexStr);
	//System.out.println("拆分後的數組:"+Arrays.toString(arrays));
	if(arrays==null||arrays.length<=0)
	{
		System.out.println("注意:數組拆分為0");
		return null;
	}
	byte[][] result=new byte[arrays.length][];
	//對子數組進行重組
	for(int i=0;i<arrays.length;i++)
	{
		String arrayStr=arrays[i];
		arrayStr=StringUtils.removeStart(arrayStr, ",");//去掉兩端的逗號
		arrayStr=StringUtils.removeEnd(arrayStr, ",");//去掉兩端的逗號
		String[] array=arrayStr.split(",");//根據子字符串中間剩餘的逗號重組為hex字符串
		result[i]=toBtyeArray(array);
	}
	return result;
}
 
開發者ID:juebanlin,項目名稱:util4j,代碼行數:40,代碼來源:HexStrBytes.java

示例7: getsonArrays

import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
 * 根據字節數組拆分若幹個字字節數組
 * @param data
 * @param separator
 * @return
 */
public byte[][] getsonArrays(byte[] data,byte[] separator)
{
	if(data==null||data.length<=0||separator==null||separator.length<=0)
	{
		System.out.println("data||separator數據無效!");
		return null;
	}
	String[] dataHexArray=byteArrayToHexArray(data);
	String dataHexStr=StringUtils.substringBetween(Arrays.toString(dataHexArray), "[", "]").replaceAll("\\s","");
	//System.out.println("待拆分字符串:"+dataHexStr);
	String[] separatorHexhArray=byteArrayToHexArray(separator);
	String separatorHexStr=StringUtils.substringBetween(Arrays.toString(separatorHexhArray), "[", "]").replaceAll("\\s","");
	//System.out.println("字符串拆分符:"+separatorHexStr);
	//得到拆分後的數組
	String[] arrays=StringUtils.splitByWholeSeparator(dataHexStr, separatorHexStr);
	//System.out.println("拆分後的數組:"+Arrays.toString(arrays));
	if(arrays==null||arrays.length<=0)
	{
		System.out.println("注意:數組拆分為0");
		return null;
	}
	byte[][] result=new byte[arrays.length][];
	//對子數組進行重組
	for(int i=0;i<arrays.length;i++)
	{
		String arrayStr=arrays[i];
		arrayStr=StringUtils.removeStart(arrayStr, ",");//去掉兩端的逗號
		arrayStr=StringUtils.removeEnd(arrayStr, ",");//去掉兩端的逗號
		String[] array=arrayStr.split(",");//根據子字符串中間剩餘的逗號重組為hex字符串
		result[i]=hexArrayToBtyeArray(array);
	}
	return result;
}
 
開發者ID:juebanlin,項目名稱:util4j,代碼行數:40,代碼來源:DataTools.java

示例8: checkJDKVersion

import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
private static boolean checkJDKVersion(String jdkVersion,boolean showPopupAndExit) {
	jdkVersion=StringUtils.removeStart(jdkVersion, "jdk");
	jdkVersion =StringUtils.remove(jdkVersion, ".");
	jdkVersion=StringUtils.remove(jdkVersion, "_");
	long version=Long.parseLong(jdkVersion);
	if(version>=REQUIRED_JDK_VERSION){
		return true; 
	}
	if(showPopupAndExit){
		showInvalidJavaHomeDialogAndExit();
	}
	return false;
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:14,代碼來源:PreStartActivity.java

示例9: isJobAlreadyOpen

import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
private boolean isJobAlreadyOpen(IPath jobFilePath) {
	
	String jobPathRelative = StringUtils.removeStart(jobFilePath.toString(), "..");
	jobPathRelative=StringUtils.removeStart(jobPathRelative, "/");
	String jobPathAbsolute = StringUtils.replace(jobPathRelative, "/", "\\");
	for (IEditorReference editorRefrence : PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
			.getEditorReferences()) {
		if (StringUtils.equals(editorRefrence.getTitleToolTip(), jobPathRelative)) {
			return true;
		}else if (StringUtils.equals(editorRefrence.getTitleToolTip(), jobPathAbsolute)) {
			return true;
		}
	}
	return false;
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:16,代碼來源:SubJobOpenAction.java

示例10: makeRenamePendingFileContents

import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
 * Return the contents of the JSON file to represent the operations
 * to be performed for a folder rename.
 */
public String makeRenamePendingFileContents() {
  SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
  sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
  String time = sdf.format(new Date());

  // Make file list string
  StringBuilder builder = new StringBuilder();
  builder.append("[\n");
  for (int i = 0; i != fileMetadata.length; i++) {
    if (i > 0) {
      builder.append(",\n");
    }
    builder.append("    ");
    String noPrefix = StringUtils.removeStart(fileMetadata[i].getKey(), srcKey + "/");

    // Quote string file names, escaping any possible " characters or other
    // necessary characters in the name.
    builder.append(quote(noPrefix));
    if (builder.length() >=
        MAX_RENAME_PENDING_FILE_SIZE - FORMATTING_BUFFER) {

      // Give up now to avoid using too much memory.
      LOG.error("Internal error: Exceeded maximum rename pending file size of "
          + MAX_RENAME_PENDING_FILE_SIZE + " bytes.");

      // return some bad JSON with an error message to make it human readable
      return "exceeded maximum rename pending file size";
    }
  }
  builder.append("\n  ]");
  String fileList = builder.toString();

  // Make file contents as a string. Again, quote file names, escaping
  // characters as appropriate.
  String contents = "{\n"
      + "  FormatVersion: \"1.0\",\n"
      + "  OperationUTCTime: \"" + time + "\",\n"
      + "  OldFolderName: " + quote(srcKey) + ",\n"
      + "  NewFolderName: " + quote(dstKey) + ",\n"
      + "  FileList: " + fileList + "\n"
      + "}\n";

  return contents;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:49,代碼來源:NativeAzureFileSystem.java


注:本文中的org.apache.commons.lang.StringUtils.removeStart方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。