java - 创建文件
时间:2020-10-19 22:28:49
收藏:0
阅读:25
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("文件已存在"); } } }
评论(0)