BufferedReader directly to byte[]

╄→尐↘猪︶ㄣ 提交于 2019-11-30 13:53:34

is there any possibility my following BufferedReader is able to put the input directly into a byte[]?

Any Reader is designed to let you read characters, not bytes. To read binary data, just use an InputStream - using BufferedInputStream to buffer it if you want.

It's not really clear what you're trying to do, but you can use something like:

BufferedInputStream input = new BufferedInputStream(sock.getInputStream());
while (!done) {
    // TODO: Rename btrar to something more meaningful
    int bytesRead = input.read(btrar);
    // Do something with the data...
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!