Send text through Bluetooth from Java Server to Android Client

丶灬走出姿态 提交于 2019-11-27 10:53:19

It looks like your BufferedWriter cache was not being flushed, the data was simply remaining in the buffer without being sent. Calling bWriter.flush() after your bWriter.write() should fix the issue and cause the data to be flushed to the output stream. You can also consider changing your code to follow this:

PrintWriter pWriter = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outStream)));

This will cause the PrintWriter output to be buffered, instead of being written immediately to the output stream, which can be inefficient.

For your purposes though, omitting the BufferedWriter should be fine, as you will most likely want an immediate flush to the output stream (which PrintWriter does).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!