Android POST java.io.FileNotFoundException: http://

发布于 2024-11-25 17:12:00 字数 1119 浏览 0 评论 0原文

您好,我正在尝试通过 POST 在 andriod 中发送字节 [] byt ia get java.io.FileNotFoundException: http://xxx.xxx .xx... ,当代码到达 inputStream = connection.getInputStream(); 时出现异常

有什么想法吗?

        byte[] array = new byte[]{1,1,2,3,4,4};

        String connectionString = "http://" + url + ":" + port + "/" + uploadApp;

        URL urle = new URL(connectionString);

        URLConnection httppost = urle.openConnection();
        connection = (HttpURLConnection) httppost;
        connection.setDoInput(true);
        connection.setDoOutput(true);
        connection.setRequestMethod("POST");
        connection.setRequestProperty("User-Agent", "Tranz-Version-t1.914");
        connection.setRequestProperty("Accept_Language", "en-US");
        connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
        outputStream = connection.getOutputStream();

        outputStream.write(array);
        outputStream.flush();
        outputStream.close();
        inputStream = connection.getInputStream(); // here i got the eception

Hi i am trying to send bytes[] via POST in andriod byt i a get java.io.FileNotFoundException: http://xxx.xxx.xx... , i got the exception when the code reach inputStream = connection.getInputStream();

any ideas ?

        byte[] array = new byte[]{1,1,2,3,4,4};

        String connectionString = "http://" + url + ":" + port + "/" + uploadApp;

        URL urle = new URL(connectionString);

        URLConnection httppost = urle.openConnection();
        connection = (HttpURLConnection) httppost;
        connection.setDoInput(true);
        connection.setDoOutput(true);
        connection.setRequestMethod("POST");
        connection.setRequestProperty("User-Agent", "Tranz-Version-t1.914");
        connection.setRequestProperty("Accept_Language", "en-US");
        connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
        outputStream = connection.getOutputStream();

        outputStream.write(array);
        outputStream.flush();
        outputStream.close();
        inputStream = connection.getInputStream(); // here i got the eception

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文