Skip to content

FileUtils

Shanti Ranjan Das edited this page Jan 24, 2020 · 2 revisions
  • getSizeFromBytes(size: Long): String
    Get the file size by passing bytes, returns KB,GB...etc.

  • isExternalStorageWritable(): Boolean
    Returns if external storage is writable or not.

  • isExternalStorageReadable(): Boolean
    Returns if external storage is readable or not.

  • getMimeType(url: String): String?
    Get mime type of provided url.

  • getDirectorySize(file: File): Long
    Get the size of the directory.

  • clearDirectory(file: File): Boolean
    Clear the directory with its contents.

  • copy(file: File, target: File): Boolean
    Copy all the contents of one file/folder to file/folder of another.

  • createZip(files: List<String>, file: File,bufferSize : Int = 2048): String?
    Create zip of files with provided files.

  • getUriFromFile(context: Context, applicationId: String, file: File): Uri?
    Method to get uri from file.

  • isExtStorageAvailable(): Boolean
    Checks if [Environment].MEDIA_MOUNTED is returned by getExternalStorageState() and therefore external storage is read- and writable.

  • zipFiles(srcFiles: Collection<String>,zipFilePath: String): Boolean

  • zipFiles(srcFilePaths: Collection<String>?,zipFilePath: String?, comment: String?): Boolean

  • zipFiles(srcFiles: Collection<File>, zipFile: File): Boolean

  • zipFiles(srcFiles: Collection<File>?, zipFile: File?, comment: String?): Boolean

  • createZipFile(srcFilePath: String, zipFilePath: String): Boolean

  • createZipFile(srcFilePath: String, zipFilePath: String, comment: String): Boolean

  • createZipFile(srcFile: File, zipFile: File): Boolean

  • createZipFile(srcFile: File?, zipFile: File?, comment: String?): Boolean

  • createZipFile(srcFile: File, rootPath: String, zos: ZipOutputStream, comment: String?): Boolean
    Create zip of files with provided files. Can throw IOException.

  • unzipFile(zipFilePath: String, destDirPath: String): List<File>?

  • unzipFile(zipFile: File, destDir: File): List<File>?

  • unzipFileByKeyword(zipFilePath: String, destDirPath: String, keyword: String?): List<File>?

  • unzipFileByKeyword(zipFile: File?, destDir: File?, keyword: String?): List<File>?

  • unzipChildFile(destDir: File, files: MutableList<File>, zf: ZipFile, entry: ZipEntry, entryName: String): Boolean
    Unzip files which are provided.Can throw IOException.

  • getFilesPath(zipFilePath: String): List<String>?

  • getFilesPath(zipFile: File?): List<String>?
    Returns the files path in zip file. Can throw IOException.

  • getComments(zipFilePath: String): List<String>?

  • getComments(zipFile: File?): List<String>?
    Returns the files comment in zip file. Can throw IOException.

Clone this wiki locally