~tritone-team/tritone/eucalyptus

« back to all changes in this revision

Viewing changes to clc/modules/core/src/main/java/edu/ucsb/eucalyptus/util/StreamConsumer.java

  • Committer: Bazaar Package Importer
  • Author(s): Dustin Kirkland
  • Date: 2009-12-01 21:09:28 UTC
  • mto: This revision was merged to the branch mainline in revision 75.
  • Revision ID: james.westby@ubuntu.com-20091201210928-o2dvg0ubljhb0ft6
Tags: upstream-1.6.1~bzr1083
ImportĀ upstreamĀ versionĀ 1.6.1~bzr1083

Show diffs side-by-side

added added

removed removed

Lines of Context:
87
87
    }
88
88
 
89
89
    public void run() {
 
90
        BufferedOutputStream outStream = null;
 
91
        FileOutputStream fileOutputStream = null;
90
92
        try {
91
93
            BufferedInputStream inStream = new BufferedInputStream(is);
92
 
            BufferedOutputStream outStream = null;
93
94
            if (file != null) {
94
 
                outStream = new BufferedOutputStream(new FileOutputStream(file));
 
95
                fileOutputStream = new FileOutputStream(file);
 
96
                                outStream = new BufferedOutputStream(fileOutputStream);
95
97
            }
96
98
            byte[] bytes = new byte[WalrusProperties.IO_CHUNK_SIZE];
97
99
            int bytesRead;
101
103
                    outStream.write(bytes, 0, bytesRead);
102
104
                }
103
105
            }
104
 
            if (outStream != null)
105
 
                outStream.close();
106
106
        } catch (IOException ex) {
107
107
            ex.printStackTrace();
 
108
        } finally {
 
109
            if (outStream != null) {
 
110
                try {
 
111
                                        outStream.close();
 
112
                        fileOutputStream.close();
 
113
                                } catch (IOException e) {
 
114
                                        e.printStackTrace();
 
115
                                }
 
116
            }
108
117
        }
109
118
    }
110
119
}