Existing requirements, a designated PPT of the desktop according to the size of 1MB to cut, will cut out the files and configuration files in a directory
ImportJava.io.File;ImportJava.io.FileInputStream;Importjava.io.FileNotFoundException;ImportJava.io.FileOutputStream;Importjava.io.IOException;Importjava.util.Properties; Public classTest { Public Static voidMain (string[] args)throwsIOException {File file=NewFile ("C:\\users\\fan\\desktop\\product. PPT "); Splitfile (file); } Public Static voidSplitfile (File file)throwsIOException {//The byte array is 1024*1024 in length, and the size is 1MB when the array is filled. Final intsize=1024*1024; //putting configuration information in the properties containerProperties pro=NewProperties (); //associating source files with read streamsFileInputStream fis=Newfileinputstream (file); //Custom Buffer Arrays byte[] buf=New byte[size]; //Purpose of CreationFileOutputStream fos=NULL; intLen=0; intCount=1; //declare a directory to hold the cut filesFile dir=NewFile ("C:\\users\\fan\\desktop\\partfiles"); //If the directory does not exist, create the if(!dir.exists ()) dir.mkdirs (); while((Len=fis.read (BUF))!=-1) {fos=NewFileOutputStream (NewFile (dir, (count++) + ". Part")); Fos.write (BUF,0, Len); Fos.close (); } pro.setproperty ("Partcount", count+ ""); Pro.setproperty ("FileName", File.getname ()); FOS=NewFileOutputStream (NewFile (dir,count+ ". Properties")); Pro.store (FOS,"Save"); Fos.close (); Fis.close (); }}
Io stream file cut, file merge Java