阅读背景:

如果我不首先抛出FileNotFoundExcetion,为什么file.exists()总是返回true

来源:互联网 
public class Main {

final private static int MAX_RECORD_NUMBER = 20;
final private static int RECORD_LENGTH = 71;

public static void main(String[] args) throws IOException, FileNotFoundException{
    Scanner input = new Scanner(System.in);
    System.out.println("Please input the file location and name.");
    String filepath = input.next();
    File file = new File(filepath); 

    boolean isExisted = file.exists(); // Problem exists here if I delete FileNotFoundException

    RandomAccessFile store = new RandomAccessFile(file, "rw");

    if (!isExisted) {
        String dummy = "Empty record                                                           ";
        for (int i = 0; i < MAX_RECORD_NUMBER; i++) {
            store.writeUTF(dummy);
        }
    }
public class Main {

final private static int M



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: