Java SE 分段读取文件
public void read() throws IOException{File f = new File("d:\\a.xml");
FileInputStream fis = new FileInputStream(f);
OutputStream os = new FileOutputStream("d:\\b.xml.copy");
byte[] buff = new byte;//2M内存
int len;
while ((len = fis.read(buff)) != -1) {
os.write(buff, 0, len);
};
os.close(); fis.close();
}
页:
[1]