Hello Ashirbad,
That's a wrapper method for a file writer - it simply writes to a file.
Byte arrays are the main input into file writers.
new ByteArrayInputStream(stream.toByteArray()) converts what I assume is an output byte array stream (or maybe a string) to an input byte array stream.
Here's a link to the java doc on byte array input streams - https://docs.oracle.com/javase/7/docs/api/java/io/ByteArrayInputStream.html