In this tutorial, we will see concerting String[] to InputStream in the following ways:
public class BuffreredReaderExample {
public static void main(String[] args) throws IOException {
String[] strArray = { "Javasavvy", "javasavvy1", "test1", "test2" };
InputStream inputStream = new ByteArrayInputStream(String.join("\n", Arrays.asList(strArray)).getBytes());
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
br.close();
System.out.println("done");
}
}