1
momocraft 2022-11-26 15:27:52 +08:00
大小正确那内容正不正确啊
|
3
wowo243 2022-11-26 15:56:00 +08:00
chmod +x 也不能执行么,md5 对比下呢
|
5
aguesuka 2022-11-26 17:56:09 +08:00
把 read 改成 readAllBytes
|
6
luozic 2022-11-26 18:10:02 +08:00
二进制文件写入不用二进制方式?
|
8
xuanbg 2022-11-26 21:34:49 +08:00
chmod 775 filename
|
9
noor OP 过了几个月了突然想起这个问题已经解决了。
问题代码:chipToolResource.getInputStream().available()获取的的字节大小并不一定准确 每个平台实现的实现不一样,windows 上是正确的,linux 上不一定正确。 文档中也有说: * <p> Note that while some implementations of {@code InputStream} will return * the total number of bytes in the stream, many will not. It is * never correct to use the return value of this method to allocate * a buffer intended to hold all data in this stream. byte[] chipToolBytes = new byte[chipToolResource.getInputStream().available()]; 换了种方式就可以了 File outputFile = new File(tmp+"/chip-cert"); OutputStream outputStream = new FileOutputStream(outputFile); byte[] buffer = new byte[1024]; int bytesRead; while ((bytesRead = inputStream.read(buffer)) != -1) { outputStream.write(buffer, 0, bytesRead); } |