testfile
来源:互联网 发布:软件系统简介 编辑:程序博客网 时间:2024/05/18 01:03
package com.ldu.file;import java.io.File;import java.io.IOException;import java.util.Date;import org.junit.Test;/* * getName()获取文件名 * getPath()获取路径 * getAbsoluteFile()获取绝对文件名(带路径) * getAbsolutePath()绝对路径 * getParent() 获取上一层文件目录 * renameTo(File name)修改文件名 */public class TestFile { @Test public void test() throws IOException{ File file = new File("F:\\io\\hello.txt"); File file1=new File("F:\\io\\io1"); File file2 = new File("F:\\io\\hello1.txt"); File file3 = new File("F:\\hello1.txt"); File file4=new File("F:\\io"); System.out.println(file.delete()); System.out.println(file.createNewFile()); System.out.println(file1.mkdir()); String[] strs=file4.list(); for (int i = 0; i < strs.length; i++) { System.out.println(strs[i]); } System.out.println("======================================"); System.out.println(file.getName()); System.out.println(file.getPath()); System.out.println(file.getAbsoluteFile()); System.out.println(file.getAbsolutePath()); System.out.println(file.getParent()); System.out.println("======================================"); System.out.println(file1.getName()); System.out.println(file1.getPath()); System.out.println(file1.getAbsoluteFile()); System.out.println(file1.getAbsolutePath()); System.out.println(file1.getParent()); System.out.println("======================================"); boolean b=file3.renameTo(file); System.out.println(b); System.out.println("======================================"); System.out.println(file.exists()); System.out.println(file.canWrite()); System.out.println(file.canRead()); System.out.println(file.isFile()); System.out.println(file.isDirectory()); System.out.println(new Date(file.lastModified())); System.out.println(file.length()); System.out.println("======================================"); }}
阅读全文
0 0
- testfile
- testfile
- testfile
- 编译实验2-在C++中读写文件(testfile.cpp)
- 哪一个命令能用来查找在文件TESTFILE中只包含四个字符的行?
- 如何更改linux文件的拥有者及用户组(chown和chgrp)--- chown root:root testfile // 使用 chown 一次性修改拥有者及组
- inputstream
- Zookeeper的作用简介
- inputstreambuffer
- GUN C++ STL中的vector的内存分配器
- Access denied for user 'root'@'127.0.0.1'
- testfile
- [整理]GPS数据包解析
- 测试相关概念
- IntelliJ 中Maven pom.xml依赖不生效解决
- 大数据一虚拟机的安装(nat)
- InputStreamReader
- Java:继承的初始化顺序
- 欢迎使用CSDN-markdown编辑器
- PyCharm 安装设置及运行程序