|
Re: try/catch help
|
Posted: Dec 2, 2002 8:34 AM
|
|
All right, but this is kind of a mess - it's for testing - and a fragment doesn't make a lot of sense, but if I'm inadvertantly doing something, I'd like to know about it! So here goes:
try
{
userid = (String) person.getAttribute("username");
long date = (System.currentTimeMillis())/1000;
String timestr = Long.toHexString(date);
byte[] datetime = Hex.fromString(timestr);
byte [] userid1 = userid.getBytes("US-ASCII");
int dlength = datetime.length;
int ulength = userid1.length;
int mlength = dlength + ulength;
byte[] mixture = new byte[mlength];
System.arraycopy(datetime,0,mixture,0,datetime.length);
System.arraycopy(userid1,0,mixture,dlength,ulength);
}
catch (NullPointerException npe)
{
npe.printStackTrace();
}
("Hex.fromString()" is a Cryptix routine, and that stuff with "person" is from uPortal routines - two packages I use. Basically, what I'm doing here is setting up a userid and date/time string to be encrypted)
In looking at the changes I'd have to make to my program to put it "into production", I felt it would be a good idea to have a try/catch block over this code, so I put it in - only to have my program then tell me that ultimately, the encryption failed. Since the try/catch was the only thing I'd changed, I commented that out and re-compiled and re-ran - and everything was fine! But why would the insertion of a try/catch construct have any effect on execution, as long as there's no error involved?
Lynn.
|
|