tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Tools and Libs > Commons IO > Basic > Touch File

Touch File 

Apache Commons IO is a java library with simple IO utilities and filters. This requires the library commons-io-2.1.jar to be in classpath. The following example shows using FileUtils.touch() API.

File Name  :  
com/bethecoder/tutorials/commons_io/tests/TouchFile.java 
Author  :  Sudhakar KV
Email  :  [email protected]
   
package com.bethecoder.tutorials.commons_io.tests;

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;

public class TouchFile {

  /**
   @param args
   @throws IOException 
   */
  public static void main(String[] argsthrows IOException {
    File file = new File("C:/Test/Test.java");
    
      //Creates an empty file or updates the last updated timestamp on the
      //same as the unix command of the same name.
    FileUtils.touch(file);
    System.out.println("Successfully touched the file");
  }
}
   

It gives the following output,
Successfully touched the file



 
  


  
bl  br