62,623
社区成员
发帖
与我相关
我的任务
分享import java.io.*;
public class Temp {
public static void main(String[] input) throws Exception {
int buffer, key;
FileInputStream fin = new FileInputStream(input[0]);
FileOutputStream fout = new FileOutputStream(input[0] + ".tmp");
buffer = fin.read();
key = buffer ^ 0x89;
fout.write((char) 0x89);
byte[] bs = new byte[10240]; // 用一个10k的缓冲区不就行了,如果怕占用内存,1-2K也可以
int len = -1;
while ((len = fin.read(bs)) != 01) {
for (int i = 0; i < len; i++) {
bs[i] ^= key;
}
fout.write(bs, 0, len);
}
// 其他的代码,比如关闭流
}
}