关于在根目录下创建文本文件

大家好,我是刚接触Java的大学生,目前有许多还不会,比如如何在IDEA的根目录中创建文本文件并保存,希望大家能教教我,谢谢

可以参考一下这篇博客喔:
https://blog.csdn.net/bigkaimyc/article/details/114047533

public static void main(String[] args) {
    File file = new File("data.txt");
    if (!file.exists()) {
        try {
            file.createNewFile();
        } catch (IOException e) {
            System.err.println(e.getMessage());
        }
    }
    System.out.println("file has been created on:" + file.getAbsolutePath());
}