/**
* nio包在jdk4出现,提供了IO流的操作效率
*
*jdk7之后的nio:
*Path:路径
*Paths:有一个静态方法返回了一个路径
* public static Path get(URI uri)
*Files:提供了静态方法供我们使用
* public static long copy(Path source,OutputStream out)//复制文件
* public static Path write(Path path,Iterable<? extends charsequence>) lines,charset cs,openoption...options)
*/
public class NIO {
public static void main(String[] args) throws FileNotFoundException, IOException {
Files.copy(Paths.get("f4.jpg"), new FileOutputStream("copy.jpg"));
// ArrayList<String> array=new ArrayList<String>();
// array.add("hello");
// array.add("java");
// Files.write(Paths.get("array.txt"),array,Charset.forName("GBK"));
}
}
NIO的简单使用
最新推荐文章于 2021-04-20 21:50:22 发布