代码拉取完成,页面将自动刷新
package chapter11;
import java.io.File;
import java.io.IOException;
public class IODemo1File {
// show new a File class
public static void main(String[] args) throws IOException {
File f = new File("C:\\Windows\\notepad.exe");
System.out.println(f); //output: C:\Windows\notepad.exe
File f2 = new File("test.txt");
System.out.println(f2);
System.out.println(f2.getName()); //test.txt
// display OS's separator
System.out.println(File.separator); // print "\" or "/"
// show File's method about path
File f3 = new File("..");
System.out.println(f3.getPath()); //..
System.out.println(f3.getAbsoluteFile()); //D:\Projects\LearnJava\01.JavaSE\11.IO\..
System.out.println(f3.getCanonicalPath()); //D:\Projects\LearnJava\01.JavaSE
System.out.println(f3.getName()); //..
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。