这是一个创建于 73 天前的主题,其中的信息可能已经有所发展或是发生改变。
1. 新创建一个文件 A
2. 读取 Resource 目录下的可执行文件(c++编译生成的可执行文件)到 A 目录下
3. 复制后的文件大小正确,但可执行文件无法使用。
Resource chipToolResource = new DefaultResourceLoader().getResource("lib/"+name);
File chipTool = new File(System.getProperty("user.dir") + "/lib/"+name);
FileOutputStream chipToolOutputStream =new FileOutputStream(chipTool) ;
byte[] chipToolBytes = new byte[chipToolResource.getInputStream().available()];
chipToolResource.getInputStream().read(chipToolBytes);
chipToolOutputStream.write(chipToolBytes);
chipToolOutputStream.close();
在 windows 下生成的文件 A 里面的可执行文件拷贝到 Linux 上可用。
但在 Linux 下生成的文件 A 里面的可执行文件不可用。
8 条回复 • 2022-11-26 21:34:49 +08:00
 |
|
3
wowo243 73 天前
chmod +x 也不能执行么,md5 对比下呢
|
 |
|
6
luozic 73 天前
二进制文件写入不用二进制方式?
|
 |
|
8
xuanbg 73 天前
chmod 775 filename
|