有了解新版的JDK处理IO流吗?编写下基础代码, 从⼀个txt⽂本⾥⾯,拷⻉⾥⾯的内容到另外⼀个 txt⽂本⾥⾯
程序员文章站
2022-04-15 18:22:55
public static void test() { try ( FileInputStream fis = new FileInputStream("/Users/xdclass/Desktop/test.txt"); BufferedInputStream bis = new BufferedInputStream(fis); FileOutputStream fos = new File...
需要关闭的资源只要实现了java.lang.AutoCloseable,就可以⾃动被关闭
try()⾥⾯可以定义多个资源,它们的关闭顺序是最后在try()定义的资源先关闭
public static void test() {
try (
FileInputStream fis = new FileInputStream("/Users/xdclass/Desktop/test.txt");
BufferedInputStream bis =
本文地址:https://blog.csdn.net/weixin_45493295/article/details/109646892