Java File Create If not Exist ensureExists(File file)

Here you can find the source of ensureExists(File file)

Description

throws RuntimeException if file does not exist

License

Apache License

Declaration

public static void ensureExists(File file) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.File;

public class Main {
    /**//from  w w  w  .ja  va 2s .  co  m
     * throws {@link RuntimeException} if file does not exist
     */
    public static void ensureExists(File file) {
        if (!file.exists()) {
            throw new RuntimeException("File '" + file.getAbsolutePath()
                    + "' does not exist.");
        }
    }
}

Related

  1. ensureExists(File dir)