How to create a new file and stream data programatically in Java?

How to create a new file and stream data programatically in Java?

You need to add below mentioned snippet to create and write the data inside the file and make sure to close the streaming.

byte data[] = ...
FileOutputStream out = new FileOutputStream("the-file-name");
out.write(data);
out.close();