|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.jdroid.java.utils.FileUtils
public abstract class FileUtils
This class contains functions for working with files within the application.
| Field Summary | |
|---|---|
static int |
BYTES_TO_MB
|
| Constructor Summary | |
|---|---|
FileUtils()
|
|
| Method Summary | |
|---|---|
static File |
checkFile(String filePath)
|
static ByteArrayInputStream |
copy(InputStream source)
|
static void |
copyStream(InputStream source,
File destin)
|
static void |
copyStream(InputStream source,
OutputStream destin)
|
static void |
copyStream(InputStream source,
OutputStream destin,
Boolean closeOutputStream)
|
static void |
createFile(String content,
String parentPath,
String fileName)
|
static File |
createTempDir()
|
static File |
createTempFile()
|
static boolean |
exist(String filePath)
|
static void |
forceDelete(File file)
Deletes an instance of File even if it is a directory containing files.If the file is a directory and has contents, then executes itself on every content. |
static long |
getDirectorySize(File directory)
Counts the size of a directory recursively (sum of the length of all files). |
static float |
getDirectorySizeInMB(File directory)
|
static long |
getFileSize(File file)
|
static float |
getFileSizeInMB(File file)
|
static byte[] |
readAsBytes(File file)
Reads the file and returns a byte array with all the information |
static byte[] |
readAsBytes(InputStream inputStream)
Reads the inputStream and returns a byte array with all the information |
static boolean |
renameOrMove(File fileToBeMoved,
File destination)
Renames or moves a determined File instance to a destination defined by another File instance.Differs from the File.renameTo(File) method in the fact that this method logs if the operation was
successful. |
static void |
safeClose(Closeable closeable)
|
static String |
toString(File file)
Receives a File and iterates over all its lines and returns a String. |
static String |
toString(InputStream in)
Receives an InputStream and iterates over all its lines and returns a String. |
static String |
toString(InputStream in,
Boolean closeStream)
|
static File |
toTempFile(String content)
|
static File |
zipFile(String directoryToZipPath)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int BYTES_TO_MB
| Constructor Detail |
|---|
public FileUtils()
| Method Detail |
|---|
public static byte[] readAsBytes(InputStream inputStream)
throws IOException
inputStream - The inputStream to be read
IOException - The exception thrown when an error reading the inputStream happens
public static byte[] readAsBytes(File file)
throws IOException
file - The file to be read
IOException - The exception thrown when an error reading the file happenspublic static File checkFile(String filePath)
filePath - The path to the file
public static boolean exist(String filePath)
filePath - The file path to the file for verify the existence
public static void forceDelete(File file)
File even if it is a directory containing files.
file - The File to be deleted.File.delete()
public static boolean renameOrMove(File fileToBeMoved,
File destination)
File instance to a destination defined by another File instance.File.renameTo(File) method in the fact that this method logs if the operation was
successful.
fileToBeMoved - The file to be renamed or moved.destination - The File instance that denotes the new location
File.renameTo(File)public static File createTempFile()
public static File createTempDir()
public static File toTempFile(String content)
public static void createFile(String content,
String parentPath,
String fileName)
public static String toString(File file)
file - The file
public static String toString(InputStream in,
Boolean closeStream)
public static String toString(InputStream in)
in - the InputStream to be converted
public static void copyStream(InputStream source,
File destin)
source - the source InputStreamdestin - the destin File
public static void copyStream(InputStream source,
OutputStream destin,
Boolean closeOutputStream)
source - the source InputStreamdestin - the destin OutputStreamcloseOutputStream -
public static void copyStream(InputStream source,
OutputStream destin)
source - the source InputStreamdestin - the destin OutputStreampublic static ByteArrayInputStream copy(InputStream source)
source - the source InputStream
ByteArrayInputStreampublic static File zipFile(String directoryToZipPath)
public static void safeClose(Closeable closeable)
public static long getDirectorySize(File directory)
directory - directory to inspect, must not be null
public static long getFileSize(File file)
public static float getDirectorySizeInMB(File directory)
public static float getFileSizeInMB(File file)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||