关于#文件创建#,#IO流#文件创建不出来,如何解决?

如题 这个是个iq流,不知道什么问题 用的ec写的,运行完没有报错,但是也不创建文件,文件创建不出来

package changzheng;

import java.io.File;
import java.io.IOException;

public class text {

public static void main(String[] args) {
    
}

  public  static  void create01(){
        //方式1 newFile(String Pathname) //根据路径构建一个File对象
        String  filePath="d:\\news1.txt";
        File file=new File(filePath);
        try {
            file.createNewFile();
             System.out.println("创建成功~");
        } catch (IOException e) {
            e.printStackTrace();
        }
       
 
 
    }

}


package changzheng;
import java.io.File;
import java.io.IOException;

public class text {
    public static void main(String[] args) {
        create01();
    }

    public  static  void create01(){
        //方式1 newFile(String Pathname) //根据路径构建一个File对象
        String  filePath="d:\\news1.txt";
        File file=new File(filePath);
        try {
            file.createNewFile();
            System.out.println("创建成功~");
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}

img

可以正常创建的呀,但是你的main方法里边没有调用创建文件的方法,main方法里边加上 text .create01();不然main方法里边什么都没有,不会执行你创建文件create01方法

img

package changzheng;

import java.io.File;
import java.io.IOException;

public class text {

public static void main(String[] args) {
     text .create01();//或者直接 create01();
}

  public  static  void create01(){
        //方式1 newFile(String Pathname) //根据路径构建一个File对象
        String  filePath="d:\\news1.txt";
        File file=new File(filePath);
        try {
            file.createNewFile();
             System.out.println("创建成功~");
        } catch (IOException e) {
            e.printStackTrace();
        }
       
 
 
    }
}

img

在main方法里创建实列了吗?
控制台输出创建成功了吗?