Reorganized IO utils. Added NonBlockingInputStreamReader

This commit is contained in:
Jonathan Bernard 2013-08-08 19:55:15 -05:00
parent db15eb8f88
commit 3f50b81362
5 changed files with 31 additions and 4 deletions

View File

@ -1,6 +1,6 @@
#Tue, 27 Nov 2012 08:38:33 -0600
#Thu, 14 Mar 2013 04:49:38 -0500
name=jdb-util
version=1.8
version=1.9
lib.local=true
build.number=2
build.number=1

View File

@ -0,0 +1,21 @@
package com.jdbernard.io;
public class NonBlockingReader implements Runnable {
private Reader rin
private LinkedList buffer = []
public void run() {
String line = null
try {
while((line = rin.readLine()) != null &&
!Thread.currentThread().isInterrupted())
storeLine(line) }
catch (InterruptedException ie) { Thread.currentThread().interrupt() } }
public synchronized String readLine() { return buffer.poll() }
private synchronized void storeLine(String line) { buffer << line }
public NonBlockingReader(def sin) {
this.rin = new InputStreamReader(sin) }
}

View File

@ -1,7 +1,12 @@
/** # NullOutputStream
* @author Jonathan Bernard (jdbernard@gmail.com)
* @copyright 2011 Jonathan Bernard
*/
package com.jdbernard.util;
import java.io.OutputStream;
/** This implementation of OutputStream drops all data sent to it. */
public class NullOutputStream extends OutputStream {
public NullOutputStream() {}

View File

@ -1,4 +1,5 @@
/** @author Jonathan Bernard (jdbernard@gmail.com)
/** # HTTP Context
* @author Jonathan Bernard (jdbernard@gmail.com)
* @copyright 2013 Jonathan Bernard. */
package com.jdbernard.net