public final class FileUtil extends Object
Modifier and Type | Method and Description |
---|---|
static void |
copy(String inputFile, String outputFile)
Creates a copy of a file.
|
static void |
createDirectories(String outPath) |
static PrintWriter |
createPrintWriter(OutputStream output, String encoding) |
static String |
createTempCopy(String file, String tempFilePrefix, String tempFilePostfix)
Creates a temporary copy of a file.
|
static String |
createTempDirectory(String tempFilePrefix)
Creates a temporary directory.
|
static File |
createTempFile(String path) |
static File |
createTempFile(String tempFilePrefix, String tempFilePostfix)
Creates a temporary file.
|
static boolean |
deleteFile(File file)
Deletes a file and returns whether the operation succeeded.
|
static boolean |
directoryExists(String path) |
static boolean |
fileExists(String path) |
static OutputStream |
getBufferedOutputStream(String filename) |
static FileOutputStream |
getFileOutputStream(File tempFile) |
static String |
getFontsDir() |
static InputStream |
getInputStreamForFile(String path) |
static String |
getParentDirectoryUri(File file) |
static RandomAccessFile |
getRandomAccessFile(File tempFile) |
static String[] |
listFilesInDirectory(String path, boolean recursive) |
static File[] |
listFilesInDirectoryByFilter(String outPath, FileFilter fileFilter) |
static String |
parentDirectory(URL url)
Returns an URL of the parent directory for the resource.
|
static boolean |
removeFiles(String[] paths)
Removes all of the passed files.
|
static OutputStream |
wrapWithBufferedOutputStream(OutputStream outputStream) |
public static String getFontsDir()
public static boolean fileExists(String path)
public static boolean directoryExists(String path)
public static File[] listFilesInDirectoryByFilter(String outPath, FileFilter fileFilter)
public static PrintWriter createPrintWriter(OutputStream output, String encoding) throws UnsupportedEncodingException
UnsupportedEncodingException
public static OutputStream getBufferedOutputStream(String filename) throws FileNotFoundException
FileNotFoundException
public static OutputStream wrapWithBufferedOutputStream(OutputStream outputStream)
public static File createTempFile(String path) throws IOException
IOException
public static FileOutputStream getFileOutputStream(File tempFile) throws FileNotFoundException
FileNotFoundException
public static InputStream getInputStreamForFile(String path) throws IOException
IOException
public static RandomAccessFile getRandomAccessFile(File tempFile) throws FileNotFoundException
FileNotFoundException
public static void createDirectories(String outPath)
public static String getParentDirectoryUri(File file) throws MalformedURLException
MalformedURLException
public static boolean deleteFile(File file)
file
- file to be deleted
public static String parentDirectory(URL url) throws URISyntaxException
url
- of resource
URISyntaxException
- if this URL is not formatted strictly according to RFC2396 and cannot be converted to a URI.
public static File createTempFile(String tempFilePrefix, String tempFilePostfix) throws IOException
tempFilePrefix
- the prefix of the copied file's name
tempFilePostfix
- the postfix of the copied file's name
IOException
- signals that an I/O exception has occurred.
public static String createTempCopy(String file, String tempFilePrefix, String tempFilePostfix) throws IOException
file
- the path to the file to be copied
tempFilePrefix
- the prefix of the copied file's name
tempFilePostfix
- the postfix of the copied file's name
IOException
- signals that an I/O exception has occurred.
public static void copy(String inputFile, String outputFile) throws IOException
inputFile
- the path to the file to be copied
outputFile
- the path, to which the passed file should be copied
IOException
- signals that an I/O exception has occurred.
public static String createTempDirectory(String tempFilePrefix) throws IOException
tempFilePrefix
- the prefix of the temporary directory's name
IOException
- signals that an I/O exception has occurred.
public static boolean removeFiles(String[] paths)
paths
- paths to files, which should be removed
Copyright © 1998–2022 iText Group NV. All rights reserved.