请教站长 板桥里人 

melinux
04-04-22 1 123

我是一个JAVA新手,现在在调用您的 随机数字 浮点数 字符串产生
算法,
为什么我这样调用时

RandomStrg RSTR= new RandomStrg();
RSTR.setCharset("a-zA-Z0-9");
RSTR.generateRandomObject();  《----这一句
RSTR.getRandom();


RSTR.generateRandomObject();这一句,总在报
unreported exception java.lang.Exception; must be caught or declared to be thrown at line 90MM, column 10




public final void generateRandomObject() throws Exception {

// check to see if the object is a SecureRandom object
if (secure) {
try {
// get an instance of a SecureRandom object
if (provider != null)
// search for algorithm in package provider
random = SecureRandom.getInstance(algorithm, provider);
else
random = SecureRandom.getInstance(algorithm);
} catch (NoSuchAlgorithmException ne) {
throw new Exception(ne.getMessage());
} catch (NoSuchProviderException pe) {
throw new Exception(pe.getMessage());
}
} else
random = new Random();
}

melinux
2004-04-22 13:01

解决了,在我的BEAN里加了

import java.security.SecureRandom;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
就好了