📄 miscfuncs.java
字号:
/* @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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -