复习知识点:相对路径与绝对路径 文件的的输入输出的简单运用
package Text;
import java.io.File;
import java.io.IOException;
public class Text_IO {
public static void main(String[] args) throws IOException {
String str="D:/java.text目录/IO_Text/src/timg.jpg";
File file=new File(str);
System.out.println(file.length());
File src=new File("src/timg.jpg");
System.out.println(src.length());
System.out.println(System.getProperty("user.dir"));//输出当前目录
//构建一个不存在的文件
src=new File("aaa/IO2.png");
System.out.println(src.getCanonicalPath());
}
}