Thursday, 14 December 2017

Convert OutputStream to String

Java Program to Convert OutputStream to String



Program:


import java.io.*;

public class OutputStreamString {

    public static void main(String[] args) throws IOException {

        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        String line = "Welcome ENGINEERSIQ";

        stream.write(line.getBytes());
        String finalString = new String(stream.toByteArray());

        System.out.println(finalString);
    }
}

OUTPUT:

Welcome ENGINEERSIQ

No comments:

Post a Comment