- 
                Notifications
    You must be signed in to change notification settings 
- Fork 4
Java creating file with Google Guava
        Ramesh Fadatare edited this page Jul 11, 2019 
        ·
        1 revision
      
    In this example, we create a new file with Google Guava library.
For the project we need the guava dependency:
<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <version>23.4-jre</version>
</dependency>import com.google.common.io.Files;
import java.io.File;
import java.io.IOException;
public class JavaCreateFileExample {    
    public static void main(String[] args) throws IOException {
        
        Files.touch(new File("src/main/resources/myfile.txt"));
    }
}The new file is created with Files.touch(). It accepts a File as a parameter.