public class TestFileUtils extends Object
Constructor and Description |
---|
TestFileUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
copy(InputStream in,
File dst)
Copies the specified InputStream to the specified destination file.
|
static File |
createTempFile(junit.framework.TestCase testcase) |
static File |
createTempFile(junit.framework.TestCase testcase,
String suffix) |
static File |
createTempFile(junit.framework.TestCase testcase,
String suffix,
String content)
Creates a temporary file for given test with given suffix in file name.
|
static File |
createTempFileFromResource(junit.framework.TestCase testCase,
String resourceName)
Creates a temporary file from the resource name given, using the resource name as the file suffix.
|
static File |
createTestDirectory()
Create and return a temporary directory that will be deleted on exit.
|
static File |
createTestDirectory(String dirNameStem,
boolean deleteOnExit)
Creates an empty directory with a name like /tmp/dirNameStem-12345678
|
static boolean |
delete(File file,
boolean recursive)
Delete a given file/directory,
A directory will always require the recursive flag to be set.
|
static void |
saveTextContentInFile(String content,
File file) |
public static File createTestDirectory()
public static File createTestDirectory(String dirNameStem, boolean deleteOnExit)
public static File createTempFile(junit.framework.TestCase testcase)
public static File createTempFileFromResource(junit.framework.TestCase testCase, String resourceName)
public static File createTempFile(junit.framework.TestCase testcase, String suffix, String content)
public static boolean delete(File file, boolean recursive)
file
- the File object to start atrecursive
- boolean to recurse if a directory is specified.true
if and only if the file or directory is
successfully deleted; false
otherwisepublic static void copy(InputStream in, File dst) throws IOException
in
- The InputStreamdst
- The destination file name.IOException
Copyright © 2006–2016 The Apache Software Foundation. All rights reserved.