注意:
这里的拆分的图片(即输入流)为上文我们拆分的图片,如果是自己通过ps把原图片切成四份的话,请看我另一篇文章http://blog.csdn.net/u011768325/article/details/37961907
package com.hcj.july21.am;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
public class TestHe {
public static void main(String[] args) throws Exception {
File f1 = new File("images/copy1.jpg");
File f2 = new File("images/copy2.jpg");
File f3 = new File("images/copy3.jpg");
File f4 = new File("images/copy4.jpg");
File out = new File("images2/treasureMap.jpg");
FileInputStream fis1 = new FileInputStream(f1);
FileInputStream fis2 = new FileInputStream(f2);
FileInputStream fis3 = new FileInputStream(f3);
FileInputStream fis4 = new FileInputStream(f4);
FileOutputStream fos = new FileOutputStream(out);
byte[] buffer = new byte[60592 + 1000];
int read1 = fis1.read(buffer);
fos.write(buffer, 0, read1);
int read2 = fis2.read(buffer);
fos.write(buffer, 0, read2);
int read3 = fis3.read(buffer);
fos.write(buffer, 0, read3);
int read4 = fis4.read(buffer);
fos.write(buffer, 0, read4);
fos.close();
fis4.close();
fis3.close();
fis2.close();
fis1.close();
System.out.println("end");
}
}