@@ -305,15 +305,14 @@ BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputS
305
305
306
306
```java
307
307
@Test
308
- void copy_pdf_to_another_pdf_with_byte_array_buffer_stream () {
308
+ void copy_pdf_to_another_pdf_buffer_stream () {
309
309
// 记录开始时间
310
310
long start = System.currentTimeMillis();
311
311
try (BufferedInputStream bis = new BufferedInputStream(new FileInputStream(" 深入理解计算机操作系统. pdf" ));
312
312
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(" 深入理解计算机操作系统- 副本. pdf" ))) {
313
- int len;
314
- byte[] bytes = new byte[4 * 1024];
315
- while ((len = bis.read(bytes)) != -1) {
316
- bos.write(bytes, 0, len);
313
+ int content;
314
+ while ((content = bis.read()) != -1) {
315
+ bos.write(content);
317
316
}
318
317
} catch (IOException e) {
319
318
e.printStackTrace();
@@ -324,15 +323,14 @@ void copy_pdf_to_another_pdf_with_byte_array_buffer_stream() {
324
323
}
325
324
326
325
@Test
327
- void copy_pdf_to_another_pdf_with_byte_array_stream () {
326
+ void copy_pdf_to_another_pdf_stream () {
328
327
// 记录开始时间
329
328
long start = System.currentTimeMillis();
330
329
try (FileInputStream fis = new FileInputStream(" 深入理解计算机操作系统. pdf" );
331
330
FileOutputStream fos = new FileOutputStream(" 深入理解计算机操作系统- 副本. pdf" )) {
332
- int len;
333
- byte[] bytes = new byte[4 * 1024];
334
- while ((len = fis.read(bytes)) != -1) {
335
- fos.write(bytes, 0, len);
331
+ int content;
332
+ while ((content = fis.read()) != -1) {
333
+ fos.write(content);
336
334
}
337
335
} catch (IOException e) {
338
336
e.printStackTrace();
@@ -358,14 +356,15 @@ void copy_pdf_to_another_pdf_with_byte_array_stream() {
358
356
359
357
```java
360
358
@Test
361
- void copy_pdf_to_another_pdf_buffer_stream () {
359
+ void copy_pdf_to_another_pdf_with_byte_array_buffer_stream () {
362
360
// 记录开始时间
363
361
long start = System.currentTimeMillis();
364
362
try (BufferedInputStream bis = new BufferedInputStream(new FileInputStream(" 深入理解计算机操作系统. pdf" ));
365
363
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(" 深入理解计算机操作系统- 副本. pdf" ))) {
366
- int content;
367
- while ((content = bis.read()) != -1) {
368
- bos.write(content);
364
+ int len;
365
+ byte[] bytes = new byte[4 * 1024];
366
+ while ((len = bis.read(bytes)) != -1) {
367
+ bos.write(bytes, 0, len);
369
368
}
370
369
} catch (IOException e) {
371
370
e.printStackTrace();
@@ -376,14 +375,15 @@ void copy_pdf_to_another_pdf_buffer_stream() {
376
375
}
377
376
378
377
@Test
379
- void copy_pdf_to_another_pdf_stream () {
378
+ void copy_pdf_to_another_pdf_with_byte_array_stream () {
380
379
// 记录开始时间
381
380
long start = System.currentTimeMillis();
382
381
try (FileInputStream fis = new FileInputStream(" 深入理解计算机操作系统. pdf" );
383
382
FileOutputStream fos = new FileOutputStream(" 深入理解计算机操作系统- 副本. pdf" )) {
384
- int content;
385
- while ((content = fis.read()) != -1) {
386
- fos.write(content);
383
+ int len;
384
+ byte[] bytes = new byte[4 * 1024];
385
+ while ((len = fis.read(bytes)) != -1) {
386
+ fos.write(bytes, 0, len);
387
387
}
388
388
} catch (IOException e) {
389
389
e.printStackTrace();
0 commit comments