slight generalization of the temporary file support
This commit is contained in:
parent
8e1ab52381
commit
b8154bf2d9
|
@ -40,17 +40,19 @@ public class TemporaryFile {
|
||||||
return streamToFile(F, input.openStream());
|
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);
|
FileOutputStream output = new FileOutputStream(F);
|
||||||
|
|
||||||
int read;
|
int read;
|
||||||
byte[] buffer = new byte[ 1024 ];
|
byte[] buffer = new byte[ 1024 ];
|
||||||
|
for(InputStream input : inputs) {
|
||||||
while ( (read = input.read(buffer)) != -1 ) {
|
while ( (read = input.read(buffer)) != -1 ) {
|
||||||
output.write(buffer, 0, read);
|
output.write(buffer, 0, read);
|
||||||
}
|
}
|
||||||
|
input.close();
|
||||||
|
}
|
||||||
|
|
||||||
output.close();
|
output.close();
|
||||||
input.close();
|
|
||||||
|
|
||||||
return F;
|
return F;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue