File类

File类

  • File testFile = new File("xxx")
    File对象指代的是文件或者文件夹,对象是存储在内存中,当显示调用.createNewFile()才会在硬盘中创建出文件。

.exist() 判断当前
.isFile()
.isDirectory()

.mkdir()
.mkdirs() 可以创建完整的路径文件(多层结构)

使用示例

File testFilePath = new File("D:/test/file");
File testFile = new File("D:/test/file/11.java");
if(!testFile.exists()){
    testFilePath.mkdirs();
    testFile.createNewFile();
}
posted @ 2017-01-23 17:02  RSDS  阅读(117)  评论(0编辑  收藏  举报