@@ -305,15 +305,14 @@ BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputS
305305
306306```java
307307@Test
308- void copy_pdf_to_another_pdf_with_byte_array_buffer_stream () {
308+ void copy_pdf_to_another_pdf_buffer_stream () {
309309 // 记录开始时间
310310 long start = System.currentTimeMillis();
311311 try (BufferedInputStream bis = new BufferedInputStream(new FileInputStream(" 深入理解计算机操作系统. pdf" ));
312312 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);
317316 }
318317 } catch (IOException e) {
319318 e.printStackTrace();
@@ -324,15 +323,14 @@ void copy_pdf_to_another_pdf_with_byte_array_buffer_stream() {
324323}
325324
326325@Test
327- void copy_pdf_to_another_pdf_with_byte_array_stream () {
326+ void copy_pdf_to_another_pdf_stream () {
328327 // 记录开始时间
329328 long start = System.currentTimeMillis();
330329 try (FileInputStream fis = new FileInputStream(" 深入理解计算机操作系统. pdf" );
331330 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);
336334 }
337335 } catch (IOException e) {
338336 e.printStackTrace();
@@ -358,14 +356,15 @@ void copy_pdf_to_another_pdf_with_byte_array_stream() {
358356
359357```java
360358@Test
361- void copy_pdf_to_another_pdf_buffer_stream () {
359+ void copy_pdf_to_another_pdf_with_byte_array_buffer_stream () {
362360 // 记录开始时间
363361 long start = System.currentTimeMillis();
364362 try (BufferedInputStream bis = new BufferedInputStream(new FileInputStream(" 深入理解计算机操作系统. pdf" ));
365363 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);
369368 }
370369 } catch (IOException e) {
371370 e.printStackTrace();
@@ -376,14 +375,15 @@ void copy_pdf_to_another_pdf_buffer_stream() {
376375}
377376
378377@Test
379- void copy_pdf_to_another_pdf_stream () {
378+ void copy_pdf_to_another_pdf_with_byte_array_stream () {
380379 // 记录开始时间
381380 long start = System.currentTimeMillis();
382381 try (FileInputStream fis = new FileInputStream(" 深入理解计算机操作系统. pdf" );
383382 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);
387387 }
388388 } catch (IOException e) {
389389 e.printStackTrace();
0 commit comments