public class MFile extends Object
MFile class.
| 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)
copyDir.
|
static void |
copyDir(File _src,
File _dest,
String _filter)
Copy a directory with content.
|
static void |
copyDir(File _src,
File _dest,
String[] _filter)
copyDir.
|
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(File _f,
String encoding)
Open and read a file.
|
static String |
readFile(InputStream _is)
Open and read a stream.
|
static String |
readFile(InputStream _is,
String encoding)
readFile.
|
static String |
readFile(Reader _is)
Open and read a file.
|
static List<String> |
readLines(File file,
boolean removeLastEmpty)
Read a file into a list line by line
|
static void |
readLines(File file,
Observer lineObserver)
readLines.
|
static void |
readLines(Reader r,
Observer lineObserver)
readLines.
|
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.
|
static void |
writeLines(File file,
List<String> lines,
boolean append)
Write a line list to a file.
|
public static String getFileSuffix(File _file)
public static String getFileSuffix(String name)
public static String getFileName(String path)
public static File getWorkingDirectory()
File object.public static String readFile(File _f)
public static String readFile(File _f, String encoding)
public static String readFile(Reader _is)
public static String readFile(InputStream _is)
_is - a InputStream object.String object.public static String readFile(InputStream _is, String encoding)
readFile.
_is - a InputStream object.encoding - a String object.String object.public static byte[] readBinaryFile(File in) throws IOException
in - a File object.IOException - if any.public static byte[] readBinary(InputStream is) throws IOException
is - a InputStream object.IOException - if any.public static byte[] readBinary(InputStream is, boolean close) throws IOException
is - a InputStream object.close - a boolean.IOException - if any.public static void readBinary(InputStream is, byte[] buffer, int offset, int length) throws IOException
is - a InputStream object.buffer - an array of byte.offset - a int.length - a int.IOException - if any.public static boolean writeFile(File _f, String _content)
public static boolean writeFile(File _f, byte[] _content)
_f - a File object._content - an array of byte.public static void writeFile(OutputStream fos, byte[] _content, int offset, int length) throws IOException
fos - a OutputStream object._content - an array of byte.offset - a int.length - a int.IOException - if any.public static void copyFile(InputStream _is, OutputStream _os)
_is - a InputStream object._os - a OutputStream object.public static String toFileName(String _name)
public static void deleteDir(File _dir)
_dir - a File object.public static void copyDir(File _src, File _dest)
public static void copyDir(File _src, File _dest, String _filter)
public static void copyDir(File _src, File _dest, FileFilter _filter)
copyDir.
_src - a File object._dest - a File object._filter - a FileFilter object.public static String normalize(String name)
public static String getFileNameOnly(String key)
public static String replaceExtension(String name, String newExtension)
public static String getMimeType(String extension)
public static void writeLines(File file, List<String> lines, boolean append) throws IOException
file - a File object.lines - a List object.append - a boolean.IOException - if any.public static List<String> readLines(File file, boolean removeLastEmpty) throws IOException
file - a File object.removeLastEmpty - If you have written line by line the last ENTER will produce an empty line, set true to remove this line.List object.IOException - if any.public static void readLines(File file, Observer lineObserver) throws IOException
readLines.
file - a File object.lineObserver - a Observer object.IOException - if any.public static void readLines(Reader r, Observer lineObserver) throws IOException
readLines.
r - a Reader object.lineObserver - a Observer object.IOException - if any.Copyright © 2016. All Rights Reserved.