io - Multiple readers for InputStream in Java -


i have inputstream i'm reading characters. multiple readers access inputstream. seems reasonable way achieve write incoming data stringbuffer or stringbuilder, , have multiple readers read that. unfortunately, stringbufferinputstream deprecated. stringreader reads string, not mutable object that's continuously being updated. options? write own?

input stream work this: once read portion it, it's gone forever. can't go , re-read it. this:

class inputstreamsplitter {   inputstreamsplitter(inputstream toreadfrom) {     this.reader = new inputstreamreader(toreadfrom);   }   void addlistener(listener l) {     this.listeners.add(l);   }   void work() {     string line = this.reader.readline();         while(line != null) {       for(listener l : this.listeners) {         l.processline(line);       }     }   } }  interface listener {   processline(string line); } 

have interested parties implement listener , add them inputstreamsplitter


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -