2
回答
file类:无法加载主类
【寻找人气王】邀新用户免费体验华为云服务,百元话费等你拿!   
import java.io.*;
public class FileTest 
{
    public static void main(String [] args) 
    {

        File f = new File("1.txt");
        if (f.exists())
        {
            f.delete();
        }
        else
        {
        try
            {
            f.createNewFile();
            }
        catch(Exception e)
            {
            e.printStackTrace();
            }
        }
        System.out.println("File name:"+f.getName());
        System.out.println("File path:"+f.getPath());
        System.out.println("File abs path:"+f.getAbsolutePath());
        System.out.println("File Parent:"+f.getParent());
        System.out.println(f.exists()?"exits":"not exist");
        System.out.println(f.canRead()?"read":"not read");
        System.out.println(f.isDirectory()?"directory":"not directory");
        System.out.println("File last modified:"+f.lastModified());
    }
}

编译没问题;解释时,找不到或无法加载主类filetest

求高手解答

举报
天台小鸭
发帖于2年前 2回/102阅
顶部