File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ public static File createFile(int kiloSize) throws IOException {
31
31
int l = (int ) Math .min (b .length , size - s );
32
32
fos .write (b , 0 , l );
33
33
s += l ;
34
- // 随机生成的文件的每一段(4M)都不一样
34
+ // 随机生成的文件的每一段(< 4M)都不一样
35
35
b = getByte ((byte ) r .nextInt ());
36
36
}
37
37
fos .flush ();
@@ -48,9 +48,10 @@ public static File createFile(int kiloSize) throws IOException {
48
48
}
49
49
50
50
private static byte [] getByte (byte b ) {
51
- byte [] bs = new byte [1024 * 4 ];
51
+ int len = 498 * 4 ;
52
+ byte [] bs = new byte [len ];
52
53
53
- for (int i = 1 ; i < 1024 * 4 ; i ++) {
54
+ for (int i = 1 ; i < len ; i ++) {
54
55
bs [i ] = b ;
55
56
}
56
57
@@ -66,8 +67,8 @@ private static byte[] getByte(byte b) {
66
67
bs [1 ] = (byte ) r .nextInt ();
67
68
bs [0 ] = (byte ) r .nextInt ();
68
69
69
- bs [1024 * 4 - 2 ] = '\r' ;
70
- bs [1024 * 4 - 1 ] = '\n' ;
70
+ bs [len - 2 ] = '\r' ;
71
+ bs [len - 1 ] = '\n' ;
71
72
return bs ;
72
73
}
73
74
You can’t perform that action at this time.
0 commit comments