我有这样的绳子 ""3333""
我要转换成 Long
但当我看到这个例外
java.lang.NumberFormatException
我试过很多方法,但我不能改变
我正试着这样做
public void addNewFriend(List<String> mobileList, String login) {
try {
List<Long> list = new ArrayList<>();
mobileList.forEach(x -> {
log.debug(x);
x=x.replace("\\\"","");
Long y = Long.parseLong(x);
log.debug(y.toString());
list.add(y);
});
log.debug(list.toString());
Set<AppUser> appUsers = appUserRepository.findByMobileNumberIn(list);
if (appUsers.size() > 0) {
AppUser appUser = appUserRepository.findByLogin(login);
appUser.friends(appUsers);
appUserRepository.save(appUser);
} else {
throw new BadRequestAlertException("cannot find user relation with author", "AppUser", "List is Empty");
}
} catch (NoSuchElementException e) {
throw new BadRequestAlertException("Cannot find User", "Url", "Check your input");
} catch (NullPointerException e) {
throw new BadRequestAlertException("cannot find user relation with author", "AppUser", "List is Empty");
} catch (Exception e) {
throw new BadRequestAlertException(e.getMessage(), "Server Error", "Check it!");
}
}
注意:我接受了Kafka的这个请求,我无法直接获得移动列表
2条答案
按热度按时间kdfy810k1#
移除多余的
\\
因为\\\"
我会找的\"
你的绳子不是这样的。输出:
wz3gfoph2#
就这样换一个换一个