Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/349.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java IOException:通过蓝牙将文件从android设备发送到PC时管道破裂_Java_Android_Eclipse_Bluetooth_Broken Pipe - Fatal编程技术网

Java IOException:通过蓝牙将文件从android设备发送到PC时管道破裂

Java IOException:通过蓝牙将文件从android设备发送到PC时管道破裂,java,android,eclipse,bluetooth,broken-pipe,Java,Android,Eclipse,Bluetooth,Broken Pipe,我正在做一个项目,尝试将任何文件从手机发送到电脑。 我采取了以下步骤,这些步骤都很有效: 找出可用的设备进行连接 配对蓝牙设备 使用BluetoothSocket连接到PC 当我尝试使用BluetoothOutputStream将byte[]写入PC时,就会出现问题 InputStream fis = null; OutputStream os = null; if (isConnected && toSend != null) {

我正在做一个项目,尝试将任何文件从手机发送到电脑。 我采取了以下步骤,这些步骤都很有效:

  • 找出可用的设备进行连接
  • 配对蓝牙设备
  • 使用BluetoothSocket连接到PC
  • 当我尝试使用
    BluetoothOutputStream
    byte[]
    写入PC时,就会出现问题

    InputStream fis = null;
        OutputStream os = null;
            if (isConnected && toSend != null) {
                try {
                    fis = new FileInputStream(toSend);
                    os = socket.getOutputStream();
                    byte[] buf = new byte[2048];
                    if(socket.isConnected()){
                        while ((fis.read(buf)) != -1) {
                            os.write(buf);
                        }
                        os.flush();
                        Log.i("tag", "write complete");
                    }
                    Log.i("tag", "socket is not yet connected");
                } catch (IOException e) {
                    e.printStackTrace();
                } 
    
    当它到达
    os.write()

    选项:断管

    显示在eclipse logcat中,我的PC上没有收到任何信息

    有人知道如何处理这个问题吗?我想是我的电脑造成的