package 练习;
import org.junit.Test;
import java.io.*;
public class PictureSecret {
@Test
public void pictureSecret() {
BufferedInputStream bi= null;
BufferedOutputStream bo= null;
try {
File fileIn=new File("F:\\java92\\src\\练习\\1.jpg");
File fileOut=new File("F:\\java92\\src\\练习\\1secret.jpg");
FileInputStream fi=new FileInputStream(fileIn);
FileOutputStream fo=new FileOutputStream(fileOut);
bi = new BufferedInputStream(fi);
bo = new BufferedOutputStream(fo);
int len;
while (( len=bi.read())!=-1) {
byte b= (byte) (len^5);
bo.write(b);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (bo!=null) {
bo.close();
}
} catch (IOException e) {
e.printStackTrace();
}
try {
if (bi!=null) {
bi.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
@Test
public void pictureReceiver()
{
BufferedInputStream bi= null;
BufferedOutputStream bo= null;
try {
File fileIn=new File("F:\\java92\\src\\练习\\1secret.jpg");
File fileOut=new File("F:\\java92\\src\\练习\\5.jpg");
FileInputStream fi=new FileInputStream(fileIn);
FileOutputStream fo=new FileOutputStream(fileOut);
bi = new BufferedInputStream(fi);
bo = new BufferedOutputStream(fo);
int len;
while ((len=bi.read())!=-1) {
byte b= (byte) (len^5);
bo.write(b);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (bo!=null) {
bo.close();
}
} catch (IOException e) {
e.printStackTrace();
}
try {
if (bi!=null) {
bi.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}