微信手表版 v1.7版本的 MD5 值为:074f4583232b28d7848c84aa13121302

以下内容为反编译后的 StreamUtil.java 源代码,内容仅作参考


package com.chenls.weixin.util;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
public class StreamUtil {
    public static int BUFFER_SIZE = 2048;
    public static int CHUNK_LENGTH = 2048;
    public static String SPEECH_TO_TEXT = "http://streaming.mobvoi.com/speech2text";

    public static void fromInStreamToOutStream(InputStream inStream, OutputStream outStream) throws IOException {
        if (outStream == null) {
            throw new IllegalArgumentException("Output stream may not be null");
        }
        try {
            byte[] bArr = new byte[BUFFER_SIZE];
            while (true) {
                int read = inStream.read(bArr);
                if (read == -1) {
                    return;
                }
                outStream.write(bArr, 0, read);
            }
        } finally {
            inStream.close();
        }
    }

    public static String readFromStream(InputStream inStream, String charset) throws IOException {
        try {
            InputStreamReader inputStreamReader = new InputStreamReader(inStream, charset);
            StringBuffer stringBuffer = new StringBuffer();
            char[] cArr = new char[1024];
            while (true) {
                int read = inputStreamReader.read(cArr);
                if (read == -1) {
                    return stringBuffer.toString();
                }
                stringBuffer.append(cArr, 0, read);
            }
        } finally {
            inStream.close();
        }
    }
}