//把一个文件切割成n个文件
import java.io.*;
class SplitDemo
{
public static void main(String[] args) throws IOException
{
method_1();
}
public static void method_1() throws IOException
{
BufferedInputStream br = new BufferedInputStream(new FileInputStream("E:\\demo1\\4.txt"));
FileOutputStream fw = null;
byte[] by = new byte[10*1024];
int len=0;
int count=1;
while((len=br.read(by))!=-1)
{
fw=new FileOutputStream("E:\\demo1\\"+(count++)+".part");
fw.write(by,0,len);
fw.close();
}
br.close();
}
}
|
|