Import Java.io.file;import Java.io.fileinputstream;import Java.io.filenotfoundexception;import Java.io.fileoutputstream;import Java.io.ioexception;import Java.util.properties;public class FileSpilte {/** * @param args * @throws ioexception *//* * File Cutter, * One read stream, corresponding to multiple output streams, and the resulting fragmented file has an ordered number */public static void Main (string[] args) throws IOException {File Destdir = new File ("Teampfile\\filepart"); File File = new file ("E:\\a-lin-give me a reason to forget. mp3"); Filesplite (File,destdir);} private static void Filesplite (file file, file Destdir) throws IOException {if (!file.exists ()) {throw new runtimeexception (destdir+ "file does not exist");} if (!destdir.exists ()) {destdir.mkdirs ();} FileInputStream fis = new FileInputStream (file); FileOutputStream fos = null;byte[] buf =new byte[1024*1024];int count = 0; int len = 0;while ((Len=fis.read (BUF))!=-1) {File Partfile = new File (Destdir, (++count) + ". Part"); fos = new Fileoutputstrea M (partfile); Fos.write (Buf,0,len); Fos.close ();} Properties Prop =new Properties ();p ROP.SetProperty ("Partcount", integer.tostring (count));p rop.setproperty ("filename", file.getname ()); File profile = new file (Destdir, (++count) + ". Properties"), Fos=new fileoutputstream (profile);p rop.store (FOS, "save"); Fos.close ();}}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
File cutter, one read stream, corresponding to multiple output streams, and the resulting fragmented files are numbered sequentially