直接上代码了: public static void testIOException() { try (FileInputStream inputStream = new FileInputStream("xxx\\a.txt"); BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream); FileOutputStream fileOutputStream = new FileOutputStream("xxx\\b.txt"); BufferedOutputStream outputStream = new BufferedOutputStream(fileOutputStream);) { int size; byte[] bytes = new byte[1024]; while ((size = bufferedInputStream.read(bytes)) != -1) { outputStream.write(bytes, 0, size); } } catch (Exception e) { e.printStackTrace(); } }