File 类的应用

1. 获取文件的绝对路径:

package com.xuzhiwen.io;

import java.io.File;
import java.io.IOException;

public class CreateFile {
    public static void main(String[] args) throws IOException {
        File file = new File("test.txt");
        if(!file.exists()){
            file.createNewFile();
            System.out.println("create success");
        }
        String path = file.getAbsolutePath();
        System.out.println("绝对路径:"+path);
    }
}

2.抽象类不能被实例化,必须生成子类后才能实现一定的功能。

原文地址:https://www.cnblogs.com/beibidewomen/p/7357764.html