01: package vicazh.hyperpool.stream;
02:
03: import java.io.*;
04:
05: class RecordStream extends Stream {
06: private File file;
07:
08: private OutputStream stream;
09:
10: RecordStream(Connection connection, OutputStream outputstream,
11: String name) throws FileNotFoundException {
12: super (connection, outputstream);
13: this .file = new File(name);
14: file.getParentFile().mkdirs();
15: this .stream = new BufferedOutputStream(new FileOutputStream(
16: file));
17: }
18:
19: public void write(int b) throws IOException {
20: super .write(b);
21: stream.write(b);
22: }
23:
24: public void flush() throws IOException {
25: super .flush();
26: stream.flush();
27: }
28:
29: public void close() throws IOException {
30: super .close();
31: stream.close();
32: ((RecordService) connection.element).add(file);
33: ((FileService) connection.element).pack();
34: }
35: }
|