checkforread.java
来自「《A first book of java》by Gary J.Bronson 」· Java 代码 · 共 28 行
JAVA
28 行
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 + =
减小字号Ctrl + -
显示快捷键?