0

有没有办法在 android 应用程序中执行二进制文件。没有 JNI 包装器方法。

请给我示例代码。

4

1 回答 1

0

尝试这个

public void pump(InputStream in, OutputStream out, int size) {
byte[] buffer = new byte[4096]; // Or whatever constant you feel like using
int done = 0;
while (done < size) {
    int read = in.read(buffer);
    if (read == -1) {
        throw new IOException("Something went horribly wrong");
    }
    out.write(buffer, 0, read);
    done += read;
}
// Maybe put cleanup code in here if you like, e.g. in.close, out.flush, out.close
     }

从此链接Read and writing binary file in Java (看到一半的文件被损坏)

于 2013-02-06T10:08:14.307 回答