public class SpiltFile {
public static void main(String[] args) throws Exception {
//分割文件
splitFile();
//合并文件
SequenceFile();
}
public static void splitFile() throws Exception
{
FileInputStream fis = new FileInputStream("视频.avi");
FileOutputStream fos = null;
for(int x = 1;x<29;x++)
{
fos = new FileOutputStream("视频"+x+".avi");
byte[] buf = new byte[1024*1024];
int len ;
if((len = fis.read(buf))!=-1)
{
fos.write(buf,0,len);
}
fos.close();
}
fis.close();
}
public static void SequenceFile() throws Exception
{
Vector<FileInputStream> vt = new Vector<FileInputStream>();
for(int x = 1;x<29;x++)
{
vt.add(new FileInputStream("视频"+x+".avi"));
}
SequenceInputStream sis = new SequenceInputStream(vt.elements());
FileOutputStream fos = new FileOutputStream("视频复制.avi");
byte[] buf = new byte[1024];
int len =0;
while((len = sis.read(buf))!=-1)
{
fos.write(buf);
}
sis.close();
fos.close();
}
}
分割连接流
最新推荐文章于 2023-08-28 22:56:46 发布