hello dude,
why dont you ask a concrete question.
do you want to convert double into
string?
btw, this is a java qustion no relation to
wo.
Sako.
----- Original Message -----
Sent: Tuesday, November 16, 2004 4:44
AM
Subject: System.out making doubles
Hello all.
Something strange is going on, and I can't
figure it out. It's probably my code, but I can't find the mistake.
I'm
trying to change System.out to a String, which I will then email to myself.
For some reason, though, everything is coming out double.
First, I
overrode ByteArrayOutputStream's two write methods to do my custom logic, like
this (collect all the writes, send message when it has more than 1000
characters or has been 30 seconds since last write):
public/color> class/color> BAOS2 extends/color> ByteArrayOutputStream { protected/color> StringBuffer body = new/color> StringBuffer(); protected/color> Timer
errorTimer = new/color> Timer();
public/color> void/color> write(int/color> b) { super/color>.write(b); body.append("write
1\r"/color>); startErrorTimer(); }
public/color>
void/color> write(byte/color>[] b, int/color> off, int/color> len) { super/color>.write(b, off,
len); body.append("write
2\r"/color>); startErrorTimer(); }
public/color>
void/color> startErrorTimer()
{ body.append("(re-)starting Error Timer\r"/color>); errorTimer.cancel(); errorTimer = new/color> Timer(); // starts or clears?
timer/color> body.append(toString()); if/color>
(body.length() > 1000/color>)
{ body.append("L = "/color> +
body.length() + " >
1000"/color>); STMailer.sendSTMessageRR("email@hidden"/color>,
"email@hidden"/color>, "!!ERROR!!"/color>, body.toString()); body
= new/color>
StringBuffer(); reset(); } else/color>
{ TimerTask sendError = new/color>
sendErrorMessageTT(); errorTimer.schedule(sendError, (long/color>)(1000
/color>* 30/color>) ); } return/color>; }
public/color>
class/color> sendErrorMessageTT extends/color> TimerTask { public/color> void/color> run() { body.append("Sent by
timer"/color>); STMailer.sendSTMessageRR("email@hidden"/color>,
"email@hidden"/color>, "!!ERROR!!"/color>, body.toString()); body
= new/color>
StringBuffer(); reset(); } }
}
Then, in
Application.java, I set the new outputs:
baos = new/color> BAOS2(); // byte array output
stream/color> PrintStream ps = new/color>
PrintStream(baos); System.setOut(ps); System.setErr(ps);
To
test it all, I do this line *once*:
System.out.println("This
is a test."/color>);
... and I get:
write
2 (re-)starting Error Timer This is a test.write 2 (re-)starting
Error Timer This is a test. Sent by timer
Notice the
repetition. Why?
Thanks for any help!
Nathan
_______________________________________________ Do not post admin
requests to the list. They will be ignored. Webobjects-dev mailing
list
(email@hidden) Help/Unsubscribe/Update your
email sent to email@hidden
|