How to create a file in Java

This page has all the common code blocks to create a file such as create a file using java, creating a temporary file, create temporary file in a directory, Create temporary file with extension, Change last modified time, Get file size.

Now, these methods may seem unimportant in the beginning but you may have to use them multiple times in your automation. Every time you want to create a screenshot and if you want to use the inbuilt TakeScreenshot in WebDriver, you will have to create a file to save the image file.

These are very important for any selenium based test automation project. 

Create a file in java code example

Create a file in Java - temp file

How to create temp file in directory

How to create temporary file with extension

How to change last modified time

How to get file size

Checkout the code repo