使用Google API写入服务器时出错

时间:2014-09-27 21:21:32

标签: java post httpurlconnection

    URL url = new URL("https://www.google.com/speech-api/v2/recognize?output=json&lang=en-us&key=mykey");
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setRequestMethod("POST");
    conn.setRequestProperty("Content-Type", "audio/x-flac; rate=16000");
    conn.setUseCaches(false);
    conn.setDoOutput(true);
    conn.setDoInput(true);
    conn.connect();
    DataOutputStream wr = new DataOutputStream(conn.getOutputStream());
    wr.write(bytearray);
    wr.flush();
    wr.close();
    InputStream stream = conn.getInputStream(); //throws io exception

所以基本上我试图发送bytearray而不是httpurlconnection java.io.IOException:在最后一行写入服务器时出错。

0 个答案:

没有答案