package com.fengyun.test;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
public class Downloads {
private static FileInputStream fileInput;
public static void main(String[] args) throws Exception{
String sourcePate = "D:/new/1.txt";
String restPate1 = "D:/new/1(1).txt";
String restPate2 = "D:/new/1(2).txt";
String restPate3 = "D:/new/1(3).txt";
File file = new File(sourcePate);
int len = (int)file.length();
byte[] buffer = new byte[len];
if(len%3==0){
// int newLen=len/3;
// fileInput = new FileInputStream(sourcePate);
// fileInput.read(buffer, 0, newLen);
// FileOutputStream fileOutput1 = new FileOutputStream(restPate1);
// fileOutput1.write(buffer, 0, newLen);
// fileInput.read(buffer, 0, newLen);
// FileOutputStream fileOutput2 = new FileOutputStream(restPate2);
// fileOutput2.write(buffer, 0, newLen);
// fileInput.read(buffer, 0, newLen);
// FileOutputStream fileOutput3 = new FileOutputStream(restPate3);
// fileOutput3.write(buffer, 0, newLen);
int newLen=len/3;
fileInput = new FileInputStream(sourcePate);
FileOutputStream fileOutput1 = new FileOutputStream(restPate1);
FileOutputStream fileOutput2 = new FileOutputStream(restPate2);
FileOutputStream fileOutput3 = new FileOutputStream(restPate3);
fileInput.read(buffer, 0, len);
fileInput.skip(0);
fileOutput1.write(buffer, 0, newLen);
fileInput.skip(3);
fileOutput2.write(buffer, 3, newLen);
fileInput.skip(6);
fileOutput3.write(buffer, 6, newLen);
}
}
}