1 package pl.psnc.dl.ege.utils;
2
3 import java.io.File;
4 import java.io.IOException;
5
6 import org.apache.commons.io.output.DeferredFileOutputStream;
7
8 import pl.psnc.dl.ege.utils.DataBuffer.Item;
9
10
11
12
13
14
15 class BufferOutputStream
16 extends DeferredFileOutputStream
17 {
18
19
20 private Item bufferItem;
21
22
23 public BufferOutputStream(int threshold, File outputFile, Item itemRef)
24 {
25 super(threshold, outputFile);
26 this.bufferItem = itemRef;
27 }
28
29
30 public BufferOutputStream(int threshold, String prefix, String suffix,
31 File directory, Item itemRef)
32 {
33 super(threshold, prefix, suffix, directory);
34 this.bufferItem = itemRef;
35 }
36
37
38 @Override
39 public void close()
40 throws IOException
41 {
42 try {
43 super.close();
44 }
45 catch (IOException ex) {
46 bufferItem.commit();
47 throw ex;
48 }
49 }
50
51 }