📄 comparefiles.java
字号:
import java.io.*;
// start of class CompareFiles
class CompareFiles
{
public static void main(String args[])
{
File fr1= null; //declare file1
File fr2= null; //declare file2
try
{
fr1=new File("TeamProj.txt"); // open File1
System.out.println(fr1+" exists");
System.out.println("The File is "+ fr1.length() +" long");
if(fr1.canRead())
System.out.println(" Ok to read");
else
System.out.println(" Not Ready to read");
if(fr1.canWrite())
System.out.println(" Ok to Write ");
else
System.out.println(" Not Ready to Write ");
}
catch(Exception e)
{
System.out.println("TeamProj.txt Not Found");
}
try
{
fr2=new File("TeamProj2.txt"); // open File2
System.out.println("The File is "+ fr2.length() +" long");
System.out.println(fr2+" exists");
if(fr2.canRead())
System.out.println(" Ok to read");
else
System.out.println(" Not Ready to read");
if(fr2.canWrite())
System.out.println(" Ok to Write ");
else
System.out.println(" Not Ready to Write ");
}
catch(Exception e)
{
System.out.println("TeamProj2.txt Not Found");
}
if(fr2.lastModified() > fr1.lastModified()) // Compare Time
System.out.println("The more Recent File is "+fr2);
else
System.out.println("The more Recent File is "+fr1);
}
} // end class CompareFiles
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -