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

Touch File 

Google Guava is a java library with lot of utilities and reusable components. This requires the library guava-10.0.jar to be in classpath. The following example shows using Files.touch() API.

File Name  :  
com/bethecoder/tutorials/guava/io_tests/TouchFileTest.java 
Author  :  Sudhakar KV
Email  :  kvenkatasudhakar@gmail.com
   
package com.bethecoder.tutorials.guava.io_tests;

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

import com.google.common.io.Files;

public class TouchFileTest {

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

}
   

It gives the following output,
Successfully touched the file


                    Print

   



Books Recommendation

 
 
bl  br