本文整理汇总了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;
}
示例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;
}
示例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;
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}