将OutputStream转换为String的Java程序 Java将OutputStream转换为String Java compareTo() 将OutputStream转换为String的Java程序 import java.io.*; public class OSString { public static void main(String[] args) throws IOException { ByteArrayOutputStream s = new ByteArrayOutputStream(); String l = "Hello java!"; s.write(l.getBytes()); String lastString = new String(s.toByteArray()); System.out.println(lastString); } } Java将OutputStream转换为String Java compareTo()