march alex's blog
hello,I am march alex
posts - 52,comments - 7,trackbacks - 0
FileCreate类的createFile方法用于创建一个新文件。
file.mkdirs()方法可用于地柜的创建目录。
main方法用于测试。
import java.io.File;
import java.io.IOException;


public class FileCreate {
    public static void createFile(String path, String filename) throws Exception {
        File file = new File(path);
        if(!file.exists()) {
            file.mkdirs();
        }
        file = new File(path, filename);
        if(!file.exists()) {
            file.createNewFile();
        }
    }
    public static void main(String[] args) throws Exception {
        createFile("D:\\test", "hello.txt");
    }
}
posted on 2015-02-13 14:38 marchalex 阅读(103) 评论(0)  编辑  收藏 所属分类: java小程序

只有注册用户登录后才能发表评论。


网站导航: