StreamTook(周考1)

xiaoxiao2021-02-28  109

package com.example.zhoukao1; import java.io.ByteArrayOutputStream; import java.io.InputStream; /** * Created by dell on 2017/8/4. */ public class StreamTook { public static String read(InputStream is) throws Exception { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); byte[] bytes = new byte[1024]; int len = 0; while ((len = is.read(bytes)) != -1) { byteArrayOutputStream.write(bytes, 0, len); } byteArrayOutputStream.close(); return byteArrayOutputStream.toString(); } }
转载请注明原文地址: https://www.6miu.com/read-64771.html

最新回复(0)