📄 checkforread.java
字号:
import java.io.*;
public class CheckForRead
{
public static void main(String[] args)
throws java.io.IOException
{
String fileName = "prices.dat";
File inFile = new File(fileName);
// check that the file exists and can be read
if (inFile.exists() == false)
{
System.out.println("The file " + fileName + " does not exist - please check and rerun.");
System.exit(1);
}
else if(inFile.canRead() == false)
{
System.out.println("The file " + fileName + " exists but does not have read permission - please check.");
System.exit(1);
}
// set up the input stream and read the file
System.out.println("The file " + fileName + " exists and can be read.");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -