slight generalization of the temporary file support

This commit is contained in:
Julian Dolby 2014-02-14 20:35:54 -05:00 committed by Michael Heilmann
parent 8e1ab52381
commit b8154bf2d9
1 changed files with 7 additions and 5 deletions

View File

@ -40,17 +40,19 @@ public class TemporaryFile {
return streamToFile(F, input.openStream());
}
public static File streamToFile(File F, InputStream input) throws IOException {
public static File streamToFile(File F, InputStream... inputs) throws IOException {
FileOutputStream output = new FileOutputStream(F);
int read;
byte[] buffer = new byte[ 1024 ];
while ( (read = input.read(buffer)) != -1 ) {
output.write(buffer, 0, read);
for(InputStream input : inputs) {
while ( (read = input.read(buffer)) != -1 ) {
output.write(buffer, 0, read);
}
input.close();
}
output.close();
input.close();
return F;
}
}