package practice;

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

public class CreateFile {

    public static void main(String[] args) {
        
        File f = new File("src/practice","hello.txt");
        
        
        if(!f.exists()) {
            try {
                f.createNewFile();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            
            System.out.println("创建成功");
        }else {
            System.out.println("文件已存在");
        }
        
    }
    
}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-04-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-24
猜你喜欢
  • 2021-06-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-18
相关资源
相似解决方案