[Java] 纯文本查看 复制代码
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class Demo1_BufferedInputStream {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
BufferedInputStream bis = new BufferedInputStream(new FileInputStream("E:\\1.jpg"));
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("E:\\crypt.jpg"));
encrypt(bis,bos);
}
private static void encrypt(BufferedInputStream bis, BufferedOutputStream bos) throws IOException {
//加密文件
int b;
while ((b = bis.read()) != -1) {
bos.write(b ^ 256);
}
bis.close();
bos.close();
}
}