Initial import into git.
[galago.git] / java / pig-galago / src / com / yahoo / pig / data / DataBagFileWriter.java
blob2cf1be28920d8918e697673cc5663c47f24158b6
1 /*
2 * Copyright (c) 2007 Yahoo! Inc. All rights reserved.
3 * See accompanying LICENSE file.
4 */
5 package com.yahoo.pig.data;
7 import java.io.BufferedOutputStream;
8 import java.io.DataOutputStream;
9 import java.io.File;
10 import java.io.FileOutputStream;
11 import java.io.IOException;
12 import java.util.Iterator;
15 public class DataBagFileWriter {
16 File store;
17 DataOutputStream out;
19 public DataBagFileWriter(File store) throws IOException{
20 this.store = store;
21 out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(store)));
24 public void write(Tuple t) throws IOException{
25 t.write(out);
28 public void write(Iterator<Tuple> iter) throws IOException{
29 while (iter.hasNext())
30 iter.next().write(out);
33 public void close() throws IOException{
34 flush();
35 out.close();
38 public void flush() throws IOException{
39 out.flush();