创建一个文件
import java.io.File; import java.io.IOException; /* *来 自 时 代 Java 公 众 号 - nowjava.com */ public class Main { public void m() { try { File file = new File("filename"); // Create file if it does not exist boolean success = file.createNewFile(); if (success) { // File did not exist and was created } else { // File already exists } } catch (IOException e) { } }//时 代 J a v a 提 供 }