本文整理了Java中org.apache.commons.lang3.StringUtils.endsWith()
方法的一些代码示例,展示了StringUtils.endsWith()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StringUtils.endsWith()
方法的具体详情如下:
包路径:org.apache.commons.lang3.StringUtils
类名称:StringUtils
方法名:endsWith
[英]Check if a CharSequence ends with a specified suffix.
nulls are handled without exceptions. Two nullreferences are considered to be equal. The comparison is case sensitive.
StringUtils.endsWith(null, null) = true
StringUtils.endsWith(null, "def") = false
StringUtils.endsWith("abcdef", null) = false
StringUtils.endsWith("abcdef", "def") = true
StringUtils.endsWith("ABCDEF", "def") = false
StringUtils.endsWith("ABCDEF", "cde") = false
StringUtils.endsWith("ABCDEF", "") = true
[中]
代码示例来源:origin: org.apache.commons/commons-lang3
/**
* <p>Case insensitive check if a CharSequence ends with a specified suffix.</p>
*
* <p>{@code null}s are handled without exceptions. Two {@code null}
* references are considered to be equal. The comparison is case insensitive.</p>
*
* <pre>
* StringUtils.endsWithIgnoreCase(null, null) = true
* StringUtils.endsWithIgnoreCase(null, "def") = false
* StringUtils.endsWithIgnoreCase("abcdef", null) = false
* StringUtils.endsWithIgnoreCase("abcdef", "def") = true
* StringUtils.endsWithIgnoreCase("ABCDEF", "def") = true
* StringUtils.endsWithIgnoreCase("ABCDEF", "cde") = false
* </pre>
*
* @see java.lang.String#endsWith(String)
* @param str the CharSequence to check, may be null
* @param suffix the suffix to find, may be null
* @return {@code true} if the CharSequence ends with the suffix, case insensitive, or
* both {@code null}
* @since 2.4
* @since 3.0 Changed signature from endsWithIgnoreCase(String, String) to endsWithIgnoreCase(CharSequence, CharSequence)
*/
public static boolean endsWithIgnoreCase(final CharSequence str, final CharSequence suffix) {
return endsWith(str, suffix, true);
}
代码示例来源:origin: Graylog2/graylog2-server
@Override
public Boolean evaluate(FunctionArgs args, EvaluationContext context) {
final String value = valueParam.required(args, context);
final String suffix = suffixParam.required(args, context);
final boolean ignoreCase = ignoreCaseParam.optional(args, context).orElse(false);
if (ignoreCase) {
return StringUtils.endsWithIgnoreCase(value, suffix);
} else {
return StringUtils.endsWith(value, suffix);
}
}
代码示例来源:origin: org.apache.commons/commons-lang3
/**
* <p>Check if a CharSequence ends with a specified suffix.</p>
*
* <p>{@code null}s are handled without exceptions. Two {@code null}
* references are considered to be equal. The comparison is case sensitive.</p>
*
* <pre>
* StringUtils.endsWith(null, null) = true
* StringUtils.endsWith(null, "def") = false
* StringUtils.endsWith("abcdef", null) = false
* StringUtils.endsWith("abcdef", "def") = true
* StringUtils.endsWith("ABCDEF", "def") = false
* StringUtils.endsWith("ABCDEF", "cde") = false
* StringUtils.endsWith("ABCDEF", "") = true
* </pre>
*
* @see java.lang.String#endsWith(String)
* @param str the CharSequence to check, may be null
* @param suffix the suffix to find, may be null
* @return {@code true} if the CharSequence ends with the suffix, case sensitive, or
* both {@code null}
* @since 2.4
* @since 3.0 Changed signature from endsWith(String, String) to endsWith(CharSequence, CharSequence)
*/
public static boolean endsWith(final CharSequence str, final CharSequence suffix) {
return endsWith(str, suffix, false);
}
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
protected boolean isPreviouslyMinifiedFile(Resource originalResource) {
String filename = originalResource.getFilename();
if (StringUtils.endsWith(filename, JS_MIN) || StringUtils.endsWith(filename, CSS_MIN)) {
return true;
}
return false;
}
代码示例来源:origin: org.apache.commons/commons-lang3
/**
* Appends the suffix to the end of the string if the string does not
* already end with the suffix.
*
* @param str The string.
* @param suffix The suffix to append to the end of the string.
* @param ignoreCase Indicates whether the compare should ignore case.
* @param suffixes Additional suffixes that are valid terminators (optional).
*
* @return A new String if suffix was appended, the same string otherwise.
*/
private static String appendIfMissing(final String str, final CharSequence suffix, final boolean ignoreCase, final CharSequence... suffixes) {
if (str == null || isEmpty(suffix) || endsWith(str, suffix, ignoreCase)) {
return str;
}
if (suffixes != null && suffixes.length > 0) {
for (final CharSequence s : suffixes) {
if (endsWith(str, s, ignoreCase)) {
return str;
}
}
}
return str + suffix.toString();
}
代码示例来源:origin: org.apache.commons/commons-lang3
if (endsWith(sequence, searchString)) {
return true;
代码示例来源:origin: org.apache.commons/commons-lang3
if (startsWith(str, wrapToken) && endsWith(str, wrapToken)) {
final int startIndex = str.indexOf(wrapToken);
final int endIndex = str.lastIndexOf(wrapToken);
代码示例来源:origin: alibaba/jvm-sandbox
private File[] toModuleJarFileArray() {
if (moduleLibDir.exists()
&& moduleLibDir.isFile()
&& moduleLibDir.canRead()
&& StringUtils.endsWith(moduleLibDir.getName(), ".jar")) {
return new File[]{
moduleLibDir
};
} else {
return convertFileCollectionToFileArray(
listFiles(moduleLibDir, new String[]{"jar"}, false)
);
}
}
代码示例来源:origin: xtuhcy/gecco
private String jsonp2Json(String jsonp) {
if (jsonp == null) {
return null;
}
jsonp = StringUtils.trim(jsonp);
if(jsonp.startsWith("try")||StringUtils.endsWith(jsonp, ")")){
if(jsonp.indexOf("catch")!=-1){
jsonp = jsonp.substring(0,jsonp.indexOf("catch"));
}
int fromIndex = jsonp.indexOf('(');
int toIndex = jsonp.lastIndexOf(')');
if(fromIndex!=-1&&toIndex!=-1){
jsonp = jsonp.substring(fromIndex+1,toIndex).trim();
return jsonp;
}
}
if (StringUtils.endsWith(jsonp, ";")) {
jsonp = StringUtils.substringBeforeLast(jsonp, ";");
jsonp = StringUtils.trim(jsonp);
}
/*if (StringUtils.endsWith(jsonp, ")")) {
String jsonStr = StringUtils.substring(jsonp, "(", ")");
jsonStr = StringUtils.trim(jsonStr);
return jsonStr;
}*/
return jsonp;
}
代码示例来源:origin: oldmanpushcart/greys-anatomy
if (StringUtils.endsWith(line, "\\")) {
代码示例来源:origin: org.apache.commons/commons-lang3
/**
* Test StringUtils.endsWith()
*/
@Test
public void testEndsWith() {
assertTrue("endsWith(null, null)", StringUtils.endsWith(null, null));
assertFalse("endsWith(FOOBAR, null)", StringUtils.endsWith(FOOBAR, null));
assertFalse("endsWith(null, FOO)", StringUtils.endsWith(null, FOO));
assertTrue("endsWith(FOOBAR, \"\")", StringUtils.endsWith(FOOBAR, ""));
assertFalse("endsWith(foobar, foo)", StringUtils.endsWith(foobar, foo));
assertFalse("endsWith(FOOBAR, FOO)", StringUtils.endsWith(FOOBAR, FOO));
assertFalse("endsWith(foobar, FOO)", StringUtils.endsWith(foobar, FOO));
assertFalse("endsWith(FOOBAR, foo)", StringUtils.endsWith(FOOBAR, foo));
assertFalse("endsWith(foo, foobar)", StringUtils.endsWith(foo, foobar));
assertFalse("endsWith(foo, foobar)", StringUtils.endsWith(bar, foobar));
assertTrue("endsWith(foobar, bar)", StringUtils.endsWith(foobar, bar));
assertTrue("endsWith(FOOBAR, BAR)", StringUtils.endsWith(FOOBAR, BAR));
assertFalse("endsWith(foobar, BAR)", StringUtils.endsWith(foobar, BAR));
assertFalse("endsWith(FOOBAR, bar)", StringUtils.endsWith(FOOBAR, bar));
// "alpha,beta,gamma,delta".endsWith("delta")
assertTrue("endsWith(\u03B1\u03B2\u03B3\u03B4, \u03B4)",
StringUtils.endsWith("\u03B1\u03B2\u03B3\u03B4", "\u03B4"));
// "alpha,beta,gamma,delta".endsWith("gamma,DELTA")
assertFalse("endsWith(\u03B1\u03B2\u03B3\u03B4, \u03B3\u0394)",
StringUtils.endsWith("\u03B1\u03B2\u03B3\u03B4", "\u03B3\u0394"));
}
代码示例来源:origin: winder/Universal-G-Code-Sender
@Override
public boolean accept(File f) {
if (f.isDirectory()) {
return true;
}
return StringUtils.endsWith(f.getName(), ".settings");
}
代码示例来源:origin: winder/Universal-G-Code-Sender
/**
* Exports the current firmware settings to a file. The file will be in JSON format with
* {@link FirmwareSettingsFile}
*
* @param settingsFile the file to write the settings to.
* @param controller the controller to get the firmware settings from
*/
public static void exportSettings(final File settingsFile, IController controller) {
File file = settingsFile;
if (!StringUtils.endsWith(settingsFile.getName(), ".settings")) {
file = new File(settingsFile.getAbsolutePath() + ".settings");
}
FirmwareSettingsFile firmwareSettingsFile = new FirmwareSettingsFileBuilder()
.setCreatedBy(System.getProperty("user.name"))
.setDate(LocalDate.now().format(DateTimeFormatter.ISO_DATE))
.setFirmwareName(controller.getFirmwareVersion())
.setName(Localization.getString("firmware.settings.exportSettingsDefaultName"))
.setSettings(controller.getFirmwareSettings().getAllSettings())
.build();
Gson gson = new GsonBuilder()
.setPrettyPrinting()
.create();
try {
String json = gson.toJson(firmwareSettingsFile);
FileUtils.writeStringToFile(file, json);
} catch (IOException e) {
LOGGER.log(Level.SEVERE, "Couldn't write the settings file " + settingsFile.getAbsolutePath(), e);
}
}
代码示例来源:origin: com.threewks.thundr/thundr-servlet-25
private String completeViewName(String view) {
if (!StringUtils.startsWith(view, "/")) {
view = "/WEB-INF/jsp/" + view;
}
if (!StringUtils.endsWith(view, ".jsp")) {
view = view + ".jsp";
}
return view;
}
}
代码示例来源:origin: com.atlassian.mail/atlassian-mail
public boolean isPrecededByStyle(final String html) {
if (isBlank(html)) {
return false;
}
for (String wiki : styleMap.values()) {
if (endsWith(html, wiki)) {
return true;
}
}
return false;
}
代码示例来源:origin: com.cognifide.qa.bb/bb-core
private static InputStream readFileFromTestResource(String path) {
String fullPath = StringUtils.endsWith(path, YAML) ? path : path + YAML;
return YamlReader.class.getClassLoader().getResourceAsStream(fullPath);
}
}
代码示例来源:origin: iterate-ch/cyberduck
public static String name(final String path) {
if(String.valueOf(Path.DELIMITER).equals(path)) {
return path;
}
if(StringUtils.endsWith(path, String.valueOf(Path.DELIMITER))) {
return FilenameUtils.getName(normalize(path));
}
return FilenameUtils.getName(path);
}
代码示例来源:origin: org.jboss.windup.utils/windup-utils
public static boolean endsWithZipExtension(String path)
{
for (String extension : getZipExtensions())
{
if (StringUtils.endsWith(path, "." + extension))
{
return true;
}
}
return false;
}
代码示例来源:origin: org.jboss.windup.utils/utils
public static boolean endsWithZipExtension(String path)
{
for (String extension : getZipExtensions())
{
if (StringUtils.endsWith(path, "." + extension))
{
return true;
}
}
return false;
}
代码示例来源:origin: apache/phoenix
if (StringUtils.endsWith(oneCmd, "\\")) {
command += StringUtils.chop(oneCmd) + "\\;";
continue;
内容来源于网络,如有侵权,请联系作者删除!