[Solved] Incompatible types; found: class java.lang.String, required: class java.io.ByteArrayOutputStream


You’re trying to assign the result of replaceAll (a String) to stream, a ByteArrayOutputStream. I think you mean to just create a new variable of type String:

ByteArrayOutputStream stream= new ByteArrayOutputStream();
String str = stream.toString().replaceAll("&lt;","<");

You can then convert the String to a byte array, using getBytes:

byte[] bytes = str.getBytes();

7

solved Incompatible types; found: class java.lang.String, required: class java.io.ByteArrayOutputStream