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.getTempDirectoryPath() and FileUtils.getUserDirectoryPath() APIs.
package com.bethecoder.tutorials.commons_io.tests; import org.apache.commons.io.FileUtils; public class VariousDirPaths { /** * @param args */ public static void main(String[] args) { System.out.println("Temp dir path : " + FileUtils.getTempDirectoryPath()); System.out.println("User dir path : " + FileUtils.getUserDirectoryPath()); } }
Temp dir path : C:\DOCUME~1\VSUDHA~1\LOCALS~1\Temp\ User dir path : C:\Documents and Settings\vsudhakar001