miscfuncs.java
来自「用于从LDAP中读取目录及各人员的信息,ecpipse项目可直接运行」· Java 代码 · 共 71 行
JAVA
71 行
/* @copyright module */
/* */
/* DISCLAIMER OF WARRANTIES: */
/* ------------------------- */
/* The following [enclosed] code is sample code created by IBM Corporation. */
/* This sample code is provided to you solely for the purpose of assisting */
/* you in the development of your applications. */
/* The code is provided "AS IS", without warranty of any kind. IBM shall */
/* not be liable for any damages arising out of your use of the sample code, */
/* even if they have been advised of the possibility of such damages. */
package com.ibm.util;
import java.util.Random;
public abstract class MiscFuncs {
public static boolean bDebug = true;
private static Random rand = new Random();
public static final int getRandom(int range) {
// Random integers that range from from 0 to range
return rand.nextInt(range + 1);
}
/**
* Is a string empty?
*
* @param str
* @return true if the string is empty. false o/w
*/
public static final boolean isStringEmpty(String str) {
if ((null == str) || (0 == str.length())) {
return true;
}
return false;
}
public static final String removeChar(String s, char c) {
String r = "";
if (!isStringEmpty(s)) {
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) != c)
r += s.charAt(i);
}
}
return r;
}
/**
* String to int.
*
* @param str -
* Input string
* @return int value of string.
*
*/
public static final int strToInt(String str) {
int ret = -1;
try {
ret = Integer.parseInt(str);
} catch (NumberFormatException e) {
}
return ret;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?