If you do not want to use other library, here is a simple function to convert InputStream
to OutputStream
.
public static void copyStream(InputStream in, OutputStream out) throws IOException {
byte[] buffer = new byte[1024];
int read;
while ((read = in.read(buffer)) != -1) {
out.write(buffer, 0, read);
}
}
Now you can easily write an Inputstream
into file by using FileOutputStream
-
FileOutputStream out = new FileOutputStream(outFile);
copyStream (inputStream, out);
out.close();