本文整理了Java中java.lang.String.equals()
方法的一些代码示例,展示了String.equals()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。String.equals()
方法的具体详情如下:
包路径:java.lang.String
类名称:String
方法名:equals
[英]Compares this string to the specified object. The result is true if and only if the argument is not null and is a String object that represents the same sequence of characters as this object.
[中]将此字符串与指定的对象进行比较。当且仅当参数不为null并且是表示与此对象相同的字符序列的字符串对象时,结果才为true。
代码示例来源:origin: stackoverflow.com
private boolean isMyServiceRunning(Class<?> serviceClass) {
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if (serviceClass.getName().equals(service.service.getClassName())) {
return true;
}
}
return false;
}
代码示例来源:origin: stackoverflow.com
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
Action action = ActionFactory.getAction(request);
String view = action.execute(request, response);
if (view.equals(request.getPathInfo().substring(1)) {
request.getRequestDispatcher("/WEB-INF/" + view + ".jsp").forward(request, response);
} else {
response.sendRedirect(view);
}
} catch (Exception e) {
throw new ServletException("Executing action failed.", e);
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public boolean test(String value) {
return "d".equals(value);
}
};
代码示例来源:origin: ReactiveX/RxJava
@Override
public boolean test(String t1) {
return t1.equals("two");
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public boolean test(String t1) {
return t1.equals("two");
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public String apply(String s) {
if (s.equals("x")) {
return "xx";
}
return s.toUpperCase();
}
};
代码示例来源:origin: ReactiveX/RxJava
@Override
public String apply(String t1) {
if ("b".equals(t1)) {
throw new RuntimeException("Forced failure");
}
return t1 + t1;
}
};
代码示例来源:origin: ReactiveX/RxJava
@Override
public String apply(String s) {
if (s.equals("x")) {
return "xx";
}
return s.toUpperCase();
}
};
代码示例来源:origin: ReactiveX/RxJava
@Override
public String apply(String t1) {
if ("bb".equals(t1)) {
throw new RuntimeException("Forced failure");
}
return t1 + t1;
}
};
代码示例来源:origin: ReactiveX/RxJava
@Override
public String apply(String t1) {
if ("bb".equals(t1)) {
throw new RuntimeException("Forced failure");
}
return t1 + t1;
}
};
代码示例来源:origin: ReactiveX/RxJava
@Override
public void accept(String s) {
if ("fail".equals(s)) {
throw new RuntimeException("Forced Failure");
}
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public String apply(String s) {
if ("fail".equals(s)) {
throw new RuntimeException("Forced Failure");
}
System.out.println("BadMapper:" + s);
return s;
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public String apply(String s) {
if ("fail".equals(s)) {
throw new RuntimeException("Forced Failure");
}
System.out.println("BadMapper:" + s);
return s;
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public Integer apply(String t1) {
if ("b".equals(t1)) {
throw new RuntimeException("Forced Failure");
}
return t1.length();
}
};
代码示例来源:origin: ReactiveX/RxJava
@Override
public String apply(String s) {
if ("fail".equals(s)) {
throw new RuntimeException("Forced Failure");
}
System.out.println("BadMapper:" + s);
return s;
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public Integer apply(String t1) {
if ("bb".equals(t1)) {
throw new RuntimeException("Forced Failure");
}
return t1.length();
}
};
代码示例来源:origin: ReactiveX/RxJava
@Override
public Integer apply(String t1) {
if ("bb".equals(t1)) {
throw new RuntimeException("Forced Failure");
}
return t1.length();
}
};
代码示例来源:origin: ReactiveX/RxJava
@Override
public Integer apply(String t1) {
if ("b".equals(t1)) {
throw new RuntimeException("Forced Failure");
}
return t1.length();
}
};
代码示例来源:origin: stackoverflow.com
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// ...
List<Part> fileParts = request.getParts().stream().filter(part -> "file".equals(part.getName())).collect(Collectors.toList()); // Retrieves <input type="file" name="file" multiple="true">
for (Part filePart : fileParts) {
String fileName = Paths.get(filePart.getSubmittedFileName()).getFileName().toString(); // MSIE fix.
InputStream fileContent = filePart.getInputStream();
// ... (do your job here)
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public String apply(Integer t) {
assertTrue(Thread.currentThread().getName().equals(currentThreadName));
return "Value_" + t + "_Thread_" + Thread.currentThread().getName();
}
});
内容来源于网络,如有侵权,请联系作者删除!