Java File Touch touch(String file)

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

Description

Create a new empty file.

License

Open Source License

Declaration

public static boolean touch(String file) throws IOException 

Method Source Code


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

import java.io.*;

public class Main {
    /**//www.  j av a2 s  .  c  o  m
     * Create a new empty file.
     */
    public static boolean touch(String file) throws IOException {
        return !exists(file) && (new File(file)).createNewFile();
    }

    /**
     * Check if a file exists.
     */
    public static boolean exists(String file) {
        return (new File(file)).exists();
    }
}

Related

  1. touch(final File file)
  2. touch(final File folder, final String fileName)
  3. touch(String _filename)
  4. touch(String answers)
  5. touch(String f)
  6. touch(String file)
  7. touch(String fileName)
  8. touch(String filePath)
  9. touch(String fullFilePath)