Import java. Io .*;
Import java. util. *; Class splitfile
{
Public static void main (string [] ARGs) throws exception
{
// Splitfile ();
Merge ();
} Public static void splitfile () throws exception {
Fileinputstream FCM = new fileinputstream ("C: \ 1.mp3 ");
Fileoutputstream Fos = NULL;
Byte [] Buf = new byte [1024*1024]; int Len = 0;
Int COUNT = 1; // create n objects cyclically
While (LEN = FS. Read (BUF ))! =-1 ){
Fos = new fileoutputstream ("C :\\ splitfiles \" + (count ++) + ". Part"); FOS. Write (BUF, 0, Len );
FOS. Close ();
}
FCM. Close ();}
// Merge?
Public static void Merge () throws exception {
Arraylist <fileinputstream> Al = new arraylist <fileinputstream> (); For (INT x = 1; x <= 17; X ++ ){
Al. Add (New fileinputstream ("C: \ splitfiles \" + x + ". Part "));
}
// Anonymous internal class, so final modification should be made to the accessed local variables
Final iterator <fileinputstream> it = Al. iterator (); enumeration <fileinputstream> en = new enumeration <fileinputstream> (){
Public Boolean hasmoreelements (){
Return it. hasnext ();
} Public fileinputstream nextelement (){
Return it. Next ();
}
};
Sequenceinputstream SIS = new sequenceinputstream (en); fileoutputstream Fos = new fileoutputstream ("C: \ splitfiles \ 1.mp3"); byte [] Buf = new byte [1024]; int Len = 0; while (LEN = sis. read (BUF ))! =-1 ){
FOS. Write (BUF, 0, Len );
}
FOS. Close ();
Sis. Close ();
}
}