1 package rydeen.io;
2
3 import java.io.IOException;
4 import java.io.InputStream;
5 import java.io.OutputStream;
6
7 import rydeen.Destination;
8 import rydeen.ProcessTarget;
9
10
11
12
13
14
15
16 public abstract class AbstractDestination implements Destination{
17
18 @Override
19 public abstract OutputStream getOutput(String className) throws IOException;
20
21 @Override
22 public abstract OutputStream getOutput(ProcessTarget target) throws IOException;
23
24 @Override
25 public void output(ProcessTarget target) throws IOException{
26 InputStream in = null;
27 OutputStream out = null;
28 try{
29 in = target.getSource();
30 out = getOutput(target);
31 byte[] data = new byte[256];
32 int read = 0;
33
34 while((read = in.read(data)) != 0){
35 out.write(data, 0, read);
36 }
37 } finally{
38 if(in != null){
39 in.close();
40 }
41 if(out != null){
42 out.close();
43 }
44 }
45 }
46
47 @Override
48 public abstract void close() throws IOException;
49
50
51
52
53 @Override
54 public boolean isClosed(){
55 return false;
56 }
57 }