public final class FileUtils extends Object
| Constructor and Description |
|---|
FileUtils() |
| Modifier and Type | Method and Description |
|---|---|
static String |
addPathComponents(String p1,
String p2,
char sepchar) |
static File |
canonicalFile(File file) |
static String |
canonicalPath(File file) |
static String |
canonicalPath(String rootPath) |
static String |
consumeBOM(InputStream in,
String default_encoding) |
static String |
consumeBOM(InputStream in,
String default_encoding,
boolean alwaysConsumeBOM) |
static boolean |
exists(File f)
returns whether the file is absolute
if a security exception is thrown, always returns false
|
static File |
getAbsoluteFile(File f) |
static File |
getCanonicalFile(File f) |
static File |
getParentFile(File f) |
static String |
getTheRealPathBecauseCanonicalizeDoesNotFixCase(File f)
Canonicalize on Win32 doesn't fix the case of the file to match what is on disk.
|
static boolean |
isAbsolute(File f)
returns whether the file is absolute
if a security exception is thrown, always returns false
|
static boolean |
isDirectory(File f)
returns whether it's a directory
if a security exception is thrown, always returns false
|
static boolean |
isFile(File f)
returns whether it's a file
if a security exception is thrown, always returns false
|
static File[] |
listFiles(File dir) |
static File[] |
listFiles(File dir,
FilenameFilter filter) |
static String |
readFile(File file,
String default_encoding) |
static String |
readFile(String filename,
String default_encoding) |
static boolean |
renameFile(File from,
File to)
Java's File.renameTo doesn't try very hard.
|
static byte[] |
toByteArray(InputStream in) |
static byte[] |
toByteArray(InputStream in,
int length) |
static URL |
toURL(File f) |
static void |
writeClassToFile(String baseDir,
String packageName,
String className,
String str) |
public static String getTheRealPathBecauseCanonicalizeDoesNotFixCase(File f)
f - public static String readFile(File file, String default_encoding) throws IOException
IOExceptionpublic static String readFile(String filename, String default_encoding) throws IOException
IOExceptionpublic static final String consumeBOM(InputStream in, String default_encoding) throws IOException
in - input streamdefault_encoding - default encoding. null or "" => system defaultIOExceptionpublic static final String consumeBOM(InputStream in, String default_encoding, boolean alwaysConsumeBOM) throws IOException
in - input streamdefault_encoding - default encoding. null or "" => system defaultalwaysConsumeBOM - If true, then consume the UTF-16 BOM.
If false use the previous behavior that consumes
a UTF-8 BOM but not a UTF-16 BOM.
This flag is useful when reading a file into
a string that is then passed to a parser. The parser may
not know to strip out the BOM.IOExceptionpublic static File getCanonicalFile(File f) throws IOException
IOExceptionpublic static File[] listFiles(File dir, FilenameFilter filter)
public static URL toURL(File f) throws MalformedURLException
MalformedURLExceptionpublic static boolean renameFile(File from, File to)
from - absolute originto - absolute targetpublic static byte[] toByteArray(InputStream in)
public static byte[] toByteArray(InputStream in, int length) throws IOException
IOExceptionpublic static void writeClassToFile(String baseDir, String packageName, String className, String str) throws IOException
IOExceptionpublic static boolean isAbsolute(File f)
public static boolean exists(File f)
public static boolean isFile(File f)
public static boolean isDirectory(File f)
Copyright © 2018 The Apache Software Foundation. All rights reserved.