2021-12-17_学习B站Java基础视频_IO流(File概述)
作者:互联网
P250:IO流(File概述)
import java.io.*; class FileDemo { public static void main(String[] args) { consMethod(); } // 创建File对象 public static void consMethod() { // 将a.txt封装成File对象。可以将已有的和未出现的文件或者文件夹封装成对象 // File f1 = new File("e:\\java1223\\day20\\abc\\a.txt"); File f1 = new File("a.txt"); File f2 = new File("e:\\java1223\\day20\\abc", "b.txt"); File d = new File("e:\\java1223\\day20\\abc"); File f3 = new File(d, "c.txt"); sop("f1:" + f1); sop("f2:" + f2); sop("f3:" + f3); File f4 = new File("e:"+File.separator+"java1223"+File.separator+"d.txt"); sop("f4:" + f4); } public static void sop(Object obj) { System.out.println(obj); } }
标签:f1,12,Java,java1223,sop,File,new,txt 来源: https://www.cnblogs.com/pingfanliliang/p/15700709.html