package test; import java.io.*; import java.sql.SQLClientInfoException; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.*; import java.util.zip.InflaterInputStream; import javax.annotation.processing.FilerException; import javax.management.RuntimeErrorException; import privateclass.Filterby_Name; import privateclass.Filterby_hidden; import privateclass.Filterby_java; import privateclass.MyBufferedReader; public class Main { private static final String space_operator = " "; private static final double pi = Math.PI; private static final String LINE_SEPARATOR = System.getProperty("line.separator"); private static final int SIZE = 1024*1024; public static void main(String[] args) throws Exception { File file = new File("D:\1.png"); File file2 = new File("d:\图片分割"); //cutting(file); mergepart(file2); } /** *文件切割 * @throws IOException */ public static void cutting(File file) throws IOException { FileInputStream fis = new FileInputStream(file); byte buf[] = new byte[SIZE]; int len = 0; int count = 1; FileOutputStream fos = null; File dirFile = new File("d:\图片分割"); if(!dirFile.exists())dirFile.mkdirs(); while((len = fis.read(buf)) != -1) { fos = new FileOutputStream(new File(dirFile,(count++) + ".part")); fos.write(buf, 0, len); } fis.close(); fos.close(); } public static void mergepart(File file2) throws IOException { List<FileInputStream> list = new ArrayList<FileInputStream>(); for(int i = 1; i <= file2.listFiles().length; i ++) { list.add(new FileInputStream(new File(file2,i + ".part"))); } Enumeration<FileInputStream> en = Collections.enumeration(list); SequenceInputStream sis = new SequenceInputStream(en); FileOutputStream fos = new FileOutputStream(new File(file2,"1.png")); byte buf [] = new byte[SIZE]; int len = 0; while((len = sis.read(buf)) != -1) { fos.write(buf,0,len); } sis.close(); fos.close(); } }