效果如题:
将一张图片拆分为四张,因为图片编码问题,拆分后只能看到第一张的效果
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");
}
}