convert byte array to bufferedreader java

Example:

package com.w3schools;
 
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
 
public class ByteArrayToBufferedReader {
  public static void main(String args[]){
	  String str = "Test Content";
	  byte[] content = str.getBytes();
	  InputStream is = null;
	  BufferedReader bfReader = null;
	  try {
	    is = new ByteArrayInputStream(content);
	    bfReader = new BufferedReader(new InputStreamReader(is));
	    String temp = null;
	    while((temp = bfReader.readLine()) != null){
	      System.out.println(temp);
	    }
	  } catch (Exception e) {
          e.printStackTrace();
      } 
  }
}

Output:

Test Content

Download this example.