文件类:
java.io.File
基本方法;
exists(): 判断这个文件是否存在 boolean值
mkdir(): 创建文件夹路径(只能建一层)--make Directory boolean值
mkdirs(): 创建文件夹路径 boolean值
createNewFile(): 创建文件
delete(): 删除文件
renameTo(File file): 对文件进行更名操作
getName: 获取文件名称
getPath: 获取文件路径
length: 获取文件大小
isDirectory: 判断这个东西是不是一个目录
isFile: 判断这个东西是不是一个文件
File[] listFiles: 获取当前这个路径下面所有的文件和文件夹
System.out.println("文件是否存在: "+file.exists()); System.out.println("mkdir创建文件夹: " + file2.mkdir()); System.out.println("mkdirs创建文件夹: " + file3.mkdirs()); System.out.println("创建一个新的文件: "+file.createNewFile()); System.out.println("删除文件: " + file.delete()); File file_new = new File("D:二阶段java 731111\aaa.txt"); System.out.println("文件改名: "+file.renameTo(file_new)); System.out.println("文件名称: "+file.getName()); System.out.println("文件长度: "+file.length()); System.out.println("是不是文件: "+file.isFile()); System.out.println("是不是目录: "+file.isDirectory()); System.out.println("文件路径: "+file.getPath());*/getPath());