-
Notifications
You must be signed in to change notification settings - Fork 0
/
Packets.java
41 lines (39 loc) · 1.23 KB
/
Packets.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package piper;
import java.io.*;
public class Packets
{ static void divide(File f)
throws Exception
{ FileInputStream in = new FileInputStream(f);
long length = f.length();
long limit = length/10;
int bytes_read;
long total_bytes = 0;
byte[] buffer = new byte[4096];
for(int i = 0;i<10;i++)
{ FileOutputStream out = new FileOutputStream(Settings.packetSendFile + i);
while((bytes_read=in.read(buffer))!=-1)
{ out.write(buffer, 0, bytes_read);
total_bytes += bytes_read;
if(total_bytes>limit)
break;
}
out.close();
total_bytes = 0;
}
in.close();
}
static void conquer(File f)
throws Exception
{ FileOutputStream out = new FileOutputStream(f);
int bytes_read;
byte[] buffer = new byte[4096];
for(int i = 0;i<10;i++)
{ FileInputStream in = new FileInputStream(Settings.packetReceiveFile + i);
while((bytes_read=in.read(buffer))!=-1)
{ out.write(buffer, 0, bytes_read);
}
in.close();
}
out.close();
}
}