StreamHandler.java :  » Net » Terracotta » com » tc » util » io » Java Open Source

Java Open Source » Net » Terracotta 
Terracotta » com » tc » util » io » StreamHandler.java
/**
 * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice.  All rights reserved.
 */
package com.tc.util.io;

import com.tc.exception.TCRuntimeException;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.InputStream;
import java.io.OutputStream;

public class StreamHandler implements Runnable {
  InputStream  in;
  OutputStream out;

  public StreamHandler(InputStream in, OutputStream out) {
    this.in = in;
    this.out = out;
  }

  public void run() {
    BufferedInputStream bin = new BufferedInputStream(in);
    BufferedOutputStream bout = new BufferedOutputStream(out);
    int i;
    try {
      while ((i = bin.read()) != -1) {
        bout.write(i);
      }
      bout.flush();
    } catch (Exception e) {
      throw new TCRuntimeException(e);
    }
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.