Java中newFile(.),newFile(),newFile(..),newFile。。。

更新时间:2023-05-25 15:41:19 阅读: 评论:0

Java中newFile(.),newFile(),newFile(..),newFile。。。
最近遇到⼀个⼩东西,File file=new File(“”);
这是什么⿁….于是,我百度和亲⾃试验了⼀下.把new File(“.”),new File(“”),new File(“..”),new File(“.\”)都玩了⼀下,话不多少,先看代码:
package test;
import java.io.File;
brmpublic class PathThings {
public static void main(String[] args) {
yvonne catterfeldtry{
//没有参数
cooperateFile fileCreateByNo=new File("");
System.out.println("fileCreateByNo=="+fileCreateByNo);
深圳英语培训班
System.out.println("fileCreateByNo=="+CanonicalPath());
System.out.println("-----------------------------");
//⼀个点的参数
File fileCreateByPoint=new File(".");
System.out.println("fileCreateByPoint=="+fileCreateByPoint);
System.out.println("fileCreateByPoint=="+CanonicalPath());
System.out.println("-----------------------------");
//两个点的参数
File fileTwoPoint = new File("..");
System.out.println("fileTwoPoint=="+fileTwoPoint);
System.out.println("fileTwoPoint=="+CanonicalPath());
System.out.println("-----------------------------");
pornograph
考研英语辅导班//⼀个点两条斜线的参数
File filePLL = new File(".\\");
billyjoelSystem.out.println("filePLL=="+filePLL);
System.out.println("filePLL=="+CanonicalPath());
System.out.println("-----------------------------");
r2d2//当前⼯作⽬录
String Property("ur.dir");
System.out.println("currentWorkPath=="+currentWorkPath);
}catch(Exception e){
System.out.println("出问题咯");
英文书名号
配角英文}
}
}
然后⼀运⾏,效果是这样的:
是不是⼀看就懂了.就是当前项⽬⼯作⽬录.
这⼀般就是在运⾏的时候,需要在当前⼯作⽬录进⾏⼀些拷贝等操作,将项⽬中的东西拷贝出去等….⾃由发挥咯. 这个demo很简单,但是蕴含着⼤道理.
欢迎⼤家指点,评论和点赞.
加油吧,年轻的程序员.

本文发布于:2023-05-25 15:41:19,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/90/122276.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:参数   拷贝   东西   指点   将项
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图