byte array to file in java

https‮l.www//:‬autturi.com
byte array to file in java
/**
 * @author lautturi.com
 * Java example: byte array to file java
 */

import java.util.*;
import java.time.*;
import java.io.*;

public class Lautturi {

	public static void main(String[] args) {
		String str = "Hello";
		byte[] myByteArray = str.getBytes();
		try (FileOutputStream fos = new FileOutputStream("test.txt")) {
			fos.write(myByteArray);
			// fos.close(); //We create an instance of "fos" inside the try,  It will automatically close the OutputStream
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}

open the file test.txt:

Hello
Created Time:2017-09-01 21:52:04  Author:lautturi