public class MFile extends Object
| Constructor and Description |
|---|
MFile() |
| Modifier and Type | Method and Description |
|---|---|
static void |
copyDir(File _src,
File _dest)
Copy a hole directory to another location.
|
static void |
copyDir(File _src,
File _dest,
FileFilter _filter) |
static void |
copyDir(File _src,
File _dest,
String _filter)
Copy a directory with content.
|
static void |
copyDir(File _src,
File _dest,
String[] _filter) |
static boolean |
copyFile(File _src,
File _dest)
Copy a file.
|
static void |
copyFile(InputStream _is,
OutputStream _os)
Copy a stream.
|
static void |
copyFile(Reader _is,
Writer _os)
Copy a stream.
|
static void |
deleteDir(File _dir)
Remove a directory and all included content.
|
static String |
getFileName(String _path)
Returns the name of the file in a path name.
|
static String |
getFileNameOnly(String key)
Returns the name without path and extension.
|
static String |
getFileSuffix(File _file)
Return the Suffix of a file.
|
static String |
getFileSuffix(String _name)
Return the Suffix of a file.
|
static String |
getMimeType(String extension)
Searching for the mime type in config and as last option have a static list of extensions.
|
static File |
getWorkingDirectory()
return the internal working directory.
|
static String |
normalize(String name)
Return a name free from problematic characters like slash, they will be changed to underscore
|
static byte[] |
readBinary(InputStream is)
Open and read a stream.
|
static byte[] |
readBinary(InputStream is,
boolean close)
Open and read a stream.
|
static void |
readBinary(InputStream is,
byte[] buffer,
int offset,
int length)
Open and read a stream.
|
static byte[] |
readBinaryFile(File in)
Open and read a file.
|
static String |
readFile(File _f)
Open and read a file.
|
static String |
readFile(InputStream _is)
Open and read a stream.
|
static String |
readFile(Reader _is)
Open and read a file.
|
static String |
readUCF(InputStream _is,
Charset charset)
Read a stream.
|
static String |
readUTF8(InputStream _is) |
static String |
replaceExtension(String name,
String newExtension)
Replace the Extension of the file
|
static String |
toFileName(String _name)
Normalize the filename, removes all special characters.
|
static boolean |
writeFile(File _f,
byte[] _content)
Open and write the content of the byte array a file.
|
static boolean |
writeFile(File _f,
String _content)
Open and write a file.
|
static void |
writeFile(OutputStream fos,
byte[] _content,
int offset,
int length)
Write the byte array to the stream.
|
public static String getFileSuffix(File _file)
public static String getFileSuffix(String _name)
public static String getFileName(String _path)
public static File getWorkingDirectory()
public static String readFile(File _f)
public static String readFile(Reader _is)
public static String readUTF8(InputStream _is) throws IOException
IOExceptionpublic static String readUCF(InputStream _is, Charset charset) throws IOException
_is - charset - The charset to be used or null for the default charsetIOExceptionpublic static String readFile(InputStream _is)
public static byte[] readBinaryFile(File in) throws IOException
IOExceptionpublic static byte[] readBinary(InputStream is) throws IOException
IOExceptionpublic static byte[] readBinary(InputStream is, boolean close) throws IOException
is - close - IOExceptionpublic static void readBinary(InputStream is, byte[] buffer, int offset, int length) throws IOException
IOExceptionpublic static boolean writeFile(File _f, String _content)
public static boolean writeFile(File _f, byte[] _content)
_f - _content - public static void writeFile(OutputStream fos, byte[] _content, int offset, int length) throws IOException
fos - _content - offset - length - IOExceptionpublic static boolean copyFile(File _src, File _dest)
_src - _dest - public static void copyFile(InputStream _is, OutputStream _os)
public static String toFileName(String _name)
_name - public static void deleteDir(File _dir)
_dir - public static void copyDir(File _src, File _dest)
_src - _dest - public static void copyDir(File _src, File _dest, String _filter)
_src - _dest - _filter - public static void copyDir(File _src, File _dest, FileFilter _filter)
public static String normalize(String name)
name - public static String getFileNameOnly(String key)
key - public static String replaceExtension(String name, String newExtension)
name - newExtension - canonicalName - string - Copyright © 2014. All rights reserved.