Skip to content
Snippets Groups Projects
Commit a21fecea authored by Nelson Tavares de Sousa's avatar Nelson Tavares de Sousa
Browse files

fixed bug #59 in ByteArrayFileWriter

parent df5e162d
No related branches found
No related tags found
No related merge requests found
......@@ -11,11 +11,13 @@ import com.google.common.io.Files;
public class ByteArrayFileWriter extends ConsumerStage<byte[]> {
private final File file;
private FileOutputStream fo;
public ByteArrayFileWriter(final File file) {
this.file = file;
try {
Files.touch(file);
fo = new FileOutputStream(this.file);
} catch (IOException e) {
e.printStackTrace();
}
......@@ -23,13 +25,20 @@ public class ByteArrayFileWriter extends ConsumerStage<byte[]> {
@Override
protected void execute(final byte[] element) {
FileOutputStream fo;
try {
fo = new FileOutputStream(this.file);
fo.write(element);
fo.close();
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
@Override
public void onTerminating() {
try {
fo.close();
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment