zl程序教程

您现在的位置是:首页 >  后端

当前栏目

java 开发中常用方法

2023-09-27 14:28:17 时间
public static List ProductInfo limitProductInfoList(List ProductInfo sourList, int rowsCount) { List ProductInfo tempList = new ArrayList (); if (sourList != null) { int sourListSize = sourList.size(); if (rowsCount sourListSize) { int subCount = sourListSize % rowsCount == 0 ? sourListSize / rowsCount : sourListSize / rowsCount + 1; int startIndext = 0; int stopIndext = 0; for (int i = 0; i subCount; i++) { stopIndext = (i == subCount - 1) ? stopIndext + sourListSize % rowsCount : stopIndext + rowsCount; tempList = new ArrayList ProductInfo (sourList.subList(startIndext, stopIndext)); startIndext = stopIndext; if (tempList.size() 0) { break; } else { tempList = sourList; return tempList; }

比较字符串是否在数组中:

 private static String[] StarArray = new String[]{"DHTL", "IHTL", "GPKG", "GDIY", "GCRU"};

ArrayUtils.contains(StarArray, "DHTL")

//验证对象为null

if (ObjectUtils.equals(sysRole, null)) {

 sysRole = this.getRole(systemCode, loginName);

}

//验证List

if (CollectionUtils.isNotEmpty(sysRoleList)) {

 sysRole = sysRoleList.get(0);

}

//验证字符串-验证时候忽略空白

if (StringUtils.isBlank(formData.getPost())){

}

//验证字符串非空

if (StringUtils.isNotEmpty(userCard.getUID()))
/**

 * 清除空白字符

 * @param str

 * @return

 public static String trimAllWhitespace(String str) {

 if (str != null) {

 int len = str.length();

 if (len 0) {

 char[] dest = new char[len];

 int destPos = 0;

 for (int i = 0; i len; ++i) {

 char c = str.charAt(i);

 if (!Character.isWhitespace(c)) {

 dest[destPos++] = c;

 return new String(dest, 0, destPos);

 return str;


public static String listToString(List String list, char separator) { return org.apache.commons.lang.StringUtils.join(list.toArray(), separator);
public static List String stringToList(String str, String separator) { return java.util.Arrays.asList(str.split(separator)); }

JavaSE成神之路 - 使用IDE开发Java程序 在上一节的学习中,我们用记事本开发了Java程序。可是实际上,我们不会真的使用记事本来开发的,而是用IDE来编写和运行Java程序。 本文介绍用EditPlus来开发的步骤。
【Java技术指南】「Unirest编程专题」一起认识一下一个“灰常”优秀的Http工具,让Http开发变得如此简单 Unirest-Java是一个轻量级的HTTP客户端库,它提供了简单易用的API,可以帮助Java开发人员快速地发送HTTP请求和处理响应。在本文中,我们将深入探讨Unirest-Java的技术细节和使用方法。