public class Files
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Files.DownloadCycle |
| Modifier and Type | Method and Description |
|---|---|
static void |
assertDirectoryExists(java.io.File file)
Throws an exception if the given file does not exist
|
static void |
assertExists(java.io.File file)
Throws an exception if the given file or directory does not exist
|
static void |
assertFileExists(java.io.File file)
Throws an exception if the given file does not exist
|
static void |
copy(java.io.File source,
java.io.File target)
Copy the source
File to the target File. |
static void |
copy(java.io.InputStream is,
java.io.OutputStream os)
Copy the
InputStream to the OutputStream. |
static java.io.File |
createTempFile(java.lang.String path)
Creates a temporary file.
|
static java.lang.String |
getRelativePath(java.io.File rootDir,
java.io.File file) |
static boolean |
isWindows()
Returns true, if the OS is windows
|
static java.lang.String |
normalizePath(java.lang.String path)
Normalizes the path to cater for Windows and other platforms
|
static java.lang.String |
normalizePath(java.lang.String path,
char from,
char to) |
static byte[] |
readBytes(java.io.File file)
Reads a
File and returns the data as a byte array |
static byte[] |
readBytes(java.io.InputStream in)
Reads an
InputStream and returns the data as a byte array |
static java.util.List<java.lang.String> |
readLines(java.io.File file)
Reads a
File and returns the list of lines |
static int |
recursiveDelete(java.io.File file)
Recursively deletes the given file whether its a file or directory returning the number
of files deleted
|
static void |
recursiveDelete(java.io.File file,
java.io.FileFilter filter)
Recursively deletes the file and any children files if its a directory
|
static java.lang.String |
toString(java.io.File file)
Reads a
File and returns a . |
static java.lang.String |
toString(java.io.File file,
java.nio.charset.Charset charset)
Reads a
File and returns a . |
static java.lang.String |
toString(java.io.InputStream inputStream)
Reads an
InputStream and returns a . |
static java.lang.String |
toString(java.io.InputStream inputStream,
java.nio.charset.Charset charset)
Reads an
InputStream and returns a . |
static java.io.File |
urlToFile(java.lang.String url,
java.lang.String tempFilePrefix,
java.lang.String tempFilePostfix) |
static java.io.File |
urlToFile(java.net.URL url,
java.lang.String tempFilePrefix,
java.lang.String tempFilePostfix)
Attempts to convert a URL to a file or copies the URL to a temporary file if it can't be easily converted
|
static void |
writeLines(java.io.File file,
java.util.List<java.lang.String> lines)
Writes the given lines to the
File |
static void |
writeToFile(java.io.File file,
byte[] content)
Writes
String content to File. |
static void |
writeToFile(java.io.File file,
java.lang.String content,
java.nio.charset.Charset charset)
Writes
String content to File. |
public static java.lang.String normalizePath(java.lang.String path)
public static java.lang.String normalizePath(java.lang.String path,
char from,
char to)
public static boolean isWindows()
public static java.io.File createTempFile(java.lang.String path)
throws java.io.IOException
java.io.IOExceptionpublic static void recursiveDelete(java.io.File file,
java.io.FileFilter filter)
public static java.lang.String toString(java.io.File file,
java.nio.charset.Charset charset)
throws java.io.IOException
File and returns a .file - charset - java.io.IOExceptionpublic static java.lang.String toString(java.io.InputStream inputStream)
throws java.io.IOException
InputStream and returns a .java.io.IOExceptionpublic static java.lang.String toString(java.io.InputStream inputStream,
java.nio.charset.Charset charset)
throws java.io.IOException
InputStream and returns a .java.io.IOExceptionpublic static java.util.List<java.lang.String> readLines(java.io.File file)
throws java.io.IOException
File and returns the list of linesjava.io.IOExceptionpublic static void writeLines(java.io.File file,
java.util.List<java.lang.String> lines)
throws java.io.IOException
Filejava.io.IOExceptionpublic static byte[] readBytes(java.io.File file)
throws java.io.IOException
File and returns the data as a byte arrayjava.io.IOExceptionpublic static byte[] readBytes(java.io.InputStream in)
throws java.io.IOException
InputStream and returns the data as a byte arrayjava.io.IOExceptionpublic static java.lang.String toString(java.io.File file)
throws java.io.IOException
File and returns a .file - java.io.IOExceptionpublic static void writeToFile(java.io.File file,
java.lang.String content,
java.nio.charset.Charset charset)
throws java.io.IOException
String content to File.file - content - charset - java.io.IOExceptionpublic static void writeToFile(java.io.File file,
byte[] content)
throws java.io.IOException
String content to File.file - content - java.io.IOExceptionpublic static void copy(java.io.File source,
java.io.File target)
throws java.io.IOException
File to the target File.source - target - java.io.IOExceptionpublic static void copy(java.io.InputStream is,
java.io.OutputStream os)
throws java.io.IOException
InputStream to the OutputStream.is - os - java.io.IOExceptionpublic static java.lang.String getRelativePath(java.io.File rootDir,
java.io.File file)
throws java.io.IOException
java.io.IOExceptionpublic static void assertExists(java.io.File file)
public static void assertFileExists(java.io.File file)
public static void assertDirectoryExists(java.io.File file)
public static int recursiveDelete(java.io.File file)
public static java.io.File urlToFile(java.lang.String url,
java.lang.String tempFilePrefix,
java.lang.String tempFilePostfix)
throws java.io.IOException
java.io.IOExceptionpublic static java.io.File urlToFile(java.net.URL url,
java.lang.String tempFilePrefix,
java.lang.String tempFilePostfix)
throws java.io.IOException
java.io.IOExceptionCopyright © 2011-2014 Red Hat. All Rights Reserved.