<分区>
Possible Duplicate:
Where will be create a new file in java, when path is not given?
我正在尝试在当前目录中创建一个 txt 文件。我运行了下面的代码,没有错误。但我无法在任何地方找到 myfile.txt。我想在当前目录中创建 myfile.txt。我该怎么做?
我使用的代码:
public void createFile(){
try{
File f = new File("myfile.txt");
if (!f.exists()){
f.createNewFile();
System.out.println("New file \"myfile.txt\" has been created");
}
}catch(Exception e){
System.out.println("Error while creating file " + e);
}
}