Re: System.out & ByteArrayOutputStream
Re: System.out & ByteArrayOutputStream
- Subject: Re: System.out & ByteArrayOutputStream
- From: Owen Jones <email@hidden>
- Date: Wed, 10 Nov 2004 15:16:35 -0500
- Organization: York University
Nathan;
You can add a method to set an external class method that you want to be called to do whatever. Then use reflection to access it (no doubt someone will step in with a suggestion to use key value coding and bindings and so on). The only purpose of it is to generalize the solution. If you're just debugging then don't bother, do the work inside the subclass.
Nathan Dumar wrote:
Thank you, Owen. I should have figured that out. I was thinking too
much and confused myself.
What is a callback?
Nathan
On Nov 10, 2004, at 2:38 PM, Owen Jones wrote:
Nathan;
Subclass ByteArrayOutputStream and override the write() methods
(there are two).
e.g. (partial, not tested):
class myByteArrayOutputStream extends ByteArrayOutputStream {
...
public void write(int b) {
super.write(b);
// do my stuff
}
...
}
Add callbacks if you need to.
Nathan Dumar wrote:
I'm reading the docs but coming up short. I want to send an email
when I get a message posted to System.out or System.err. So far, I
have ...
// none of this has been tested yet
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos);
System.setOut(ps);
System.setErr(ps);
I can do baos.toString() to get the String I need for the body of
the email. The problem is that when my ByteArrayOutputStream baos
gets written to, I need to do stuff, then send the email.
I can't figure out a way to set off another method after baos gets
data. Any ideas?
Thank you,
Nathan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
--
Regards, Owen Jones
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS d+ s+:+ a+ C+ UL P+ L++ E W++ N++ o-- K- w O-- M- V-- PS+ PE Y+
PGP- t 5++ X R !tv b DI+ D++ G e++ h+ r--- y+ ------END GEEK CODE
BLOCK------
----------- SETI@Home Stats: 10561WU/12.16yrs -----------
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
--
Regards, Owen Jones
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS d+ s+:+ a+ C+ UL P+ L++ E W++ N++ o-- K- w
O-- M- V-- PS+ PE Y+ PGP- t 5++ X R !tv b DI+ D++
G e++ h+ r--- y+
------END GEEK CODE BLOCK------
----------- SETI@Home Stats: 10561WU/12.16yrs -----------
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden