Merge multiple shards
Secuenceinputstream [sequence stream, merge of two streams] SiC = new secuenceinputstream (fis1, fis2 );
[Merge multiple streams] secuenceinputstream [enumeration object] SiC = new secuenceinputstream (enumeration <inputstream> en );
1. Store sets with vector objects
Vector <fileinputstream> V = new vector <fileinputstream> ();
For (INT I = 1; I <= 4; I ++ ){
V. Add ("New fileinputstream (" Res/"+ I +". Part ")");
}
Sequenceinputstream SIS = new sequenceinputstream (V. Elements ());
Fileoutputstream Fos = new fileoutputstream(4241.mp3 ");
Byte [] Buf = new byte [1024*4];
Int Len = 0;
While (LEN = sis. Read (BUF ))! =-1 ){
FOS. Write (bus, 0, Len );
}
2. arraylist is used to improve efficiency.
Arraylist <fileinputstream> alist = new arraylist <fileinputstream> ();
For (INT I = 1; I <= 6; I ++ ){
Alist. Add (New fileinputstream (I + ". Part "));
}
Final iterator [interface] <fileinputstream> it [iterator object] = new alist. iterator ();
Class myenum implements enumeration <fileinputstream> {
Public Boolean hasmoreelements (){
Return it. hasnext ();
}
Public fileinputstream nextelements (){
Return it... Next ();
}
Myenum en = new myenum;
Sequenceinputstream SIS = new sequenceinputstream (en );
Fileoutputstream Fos = new fileoutputstream(4241.mp3 ");
Byte [] Buf = new byte [1024*4];
Int Len = 0;
While (LEN = sis. Read (BUF ))! =-1 ){
FOS. Write (bus, 0, Len );
}
}