Java File Touch touch(File file)

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

Description

touch

License

Apache License

Declaration

public static void touch(File file) 

Method Source Code

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

import java.io.File;

import java.io.IOException;

public class Main {

    public static void touch(File file) {
        if (file.exists()) {
            return;
        }//from w  ww  . ja va2s.c o m
        try {
            boolean success = file.createNewFile();
            if (!success) {
                throw new RuntimeException("can't create file. [" + file
                        + "]");
            }
        } catch (IOException e) {
            throw new RuntimeException("can't create file. [" + file + "]");
        }

    }
}

Related

  1. touch(File file)
  2. touch(File file)
  3. touch(File file)
  4. touch(File file)
  5. touch(File file)
  6. touch(File file)
  7. touch(File file)
  8. touch(File file)
  9. touch(File file)