In this section we will be showing a java source code that would check the temp directory. The temp directory is where the files would get created once a createTempFile method of File class has been called. This is essential to know since in a practical scenario, we might be bumping into disk space constraint during java runtime execution.

package com.javatutorialhq.tutorial;

public class TempDirCheck {

	/**
	 * This sample source code shows
	 * how to get the location of temp folder
	 * Property of javatutorialhq.com
	 * All Rights Reserved
	 * Version 1.0
	 * 08/25/2012
	 */

	public static void main(String[] args) {
		String tempDir = System.getProperty("java.io.tmpdir");
		System.out.println("Temporary file will be stored here : "+tempDir);

	}

}

The output of above source code differs depending on your machine settings. Running this on my machine produces below output:

Temporary file will be stored here : C:\Users\ryan\AppData\Local\Temp\