• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: System.out & ByteArrayOutputStream
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
References: 
 >System.out & ByteArrayOutputStream (From: Nathan Dumar <email@hidden>)
 >Re: System.out & ByteArrayOutputStream (From: Owen Jones <email@hidden>)
 >Re: System.out & ByteArrayOutputStream (From: Nathan Dumar <email@hidden>)

  • Prev by Date: Re: System.out & ByteArrayOutputStream
  • Next by Date: Simultaneous error messages and Autocomplete
  • Previous by thread: Re: System.out & ByteArrayOutputStream
  • Next by thread: Re: PostgreSQL Adaptor and Plugin
  • Index(es):
    • Date
    • Thread