File 类的构造方法

时间:2019-05-28 21:11:23   收藏:0   阅读:119
 1 import java.io.File;
 2 
 3 /*
 4  * File 的构造方法:
 5  *         File(File parent, String child) :从父抽象路径名和子路径名字符串创建新的 File实例
 6  *         File(String pathname) :通过将给定的路径名字符串转换为抽象路径名来创建新的 File实例
 7  *         File(String parent, String child) : 从父路径名字符串和子路径名字符串创建新的 File实例         
 8  *
 9  */
10 @SuppressWarnings("unused")
11 public class FileDemo {
12 
13     public static void main(String[] args) {
14         
15         //File(String pathname) : 将指定的路径转换成一个File对象
16         File file = new File("D:\\file\\a.txt");
17         
18         //File(File parent, String child) :从父抽象路径名和子路径名字符串创建新的 File实例
19         File file2 = new File(new File("D:\\file"), "a.txt");
20         
21         //File(String parent, String child) : 从父路径名字符串和子路径名字符串创建新的 File实例
22         File file3 = new File("D:\\file", "a.txt");
23         
24     }
25 }

 

原文:https://www.cnblogs.com/li1234567980/p/10940155.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!