Java File Touch touchOrCrash(File f)

Here you can find the source of touchOrCrash(File f)

Description

touch Or Crash

License

Open Source License

Declaration

public static void touchOrCrash(File f) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.File;

import java.io.IOException;

public class Main {
    public static void touchOrCrash(File f) throws IOException {
        if (!f.exists()) {
            f.getParentFile().mkdirs();//w  w  w  .  j a v a2  s  .c  om
            f.createNewFile();
        }
        if (!f.isFile())
            throw new RuntimeException("\"" + f.getAbsolutePath() + "\" must be a file. Aborting.");
    }
}

Related

  1. touchExisting(File file)
  2. touchFile(File directory, String name)
  3. touchFile(File file)
  4. touchFile(File file)
  5. touchFile(String target)
  6. touchRecursive(File f, long timestamp)