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) {
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上没有收到任何信息
有人知道如何处理这个问题吗?我想是我的电脑造成的