在没有给出路径的情况下,在java中创建新文件的位置? [英] Where will be create a new file in java, when path is not given?

查看:95
本文介绍了在没有给出路径的情况下,在java中创建新文件的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在java中,

File f;
f = new File("myfile.txt");
if (!f.exists()) 
{
    f.createNewFile();
}

执行上述代码时,默认情况下分配哪条路径,而具体路径没有给出?

when excute the above code,which path is assigned in default, while specific path is not given?

推荐答案

当前目录,您可以致电:

The current directory, which you can get by calling:

new File('.').getCanonicalPath();

这篇关于在没有给出路径的情况下,在java中创建新文件的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆