ScriptFile

interface ScriptFile

脚本中使用的文件.

Author

M8Test, [email protected], https://m8test.com

Functions

Link copied to clipboard
abstract fun appendBytes(byteArray: ByteArray)

将字节数组追加到此文件的内容中.

Link copied to clipboard
abstract fun appendText(text: String, charset: String)

使用指定的字符集将文本追加到此文件的内容中.

Link copied to clipboard
abstract fun copyRecursively(dest: ScriptFile, override: Boolean): Boolean

将此文件及其所有子文件复制到指定的目标路径. 如果目标路径上缺少某些目录, 则将创建它们.

Link copied to clipboard
abstract fun copyTo(dest: ScriptFile, override: Boolean): String

将此文件复制到给定的目标文件.

Link copied to clipboard
abstract fun createNewFile(): Boolean

当且仅当具有此名称的文件尚不存在时, 原子地创建一个由此抽象路径名命名的新空文件.

Link copied to clipboard
abstract fun delete(): Boolean

删除此抽象路径名表示的文件或目录.如果此路径名表示目录, 则目录必须为空才能删除.

Link copied to clipboard
abstract fun deleteRecursively(): Boolean

删除此文件及其所有子文件. 请注意,如果此操作失败,则可能已发生部分删除.

Link copied to clipboard
abstract fun exists(): Boolean

测试此抽象路径名表示的文件或目录是否存在.

Link copied to clipboard
abstract fun forEachLine(charset: String, action: (String) -> Unit)

使用指定的字符集逐行读取此文件, 并为每一行调用 action , 您可以在大文件上使用此函数.

Link copied to clipboard
abstract fun getAbsolutePath(): String

返回此文件的绝对路径.

Link copied to clipboard
abstract fun getCanonicalPath(): String

返回此抽象路径名的规范路径名字符串.

Link copied to clipboard
abstract fun getExtension(): String

获取此文件的扩展名(不包括点), 如果没有扩展名, 则返回空字符串.

Link copied to clipboard
abstract fun getFile(): File

获取此文件对应的 java File.

Link copied to clipboard
abstract fun getName(): String

返回此抽象路径名表示的文件或目录的名称.

Link copied to clipboard

获取不带扩展名的文件名.

Link copied to clipboard
abstract fun getParent(): String?

获取父路径, 行为类似 getPath.

Link copied to clipboard
abstract fun getParentFile(): ScriptFile?

获取父路径对应的 ScriptFile.

Link copied to clipboard
abstract fun getPath(): String

文件路径,已去除前缀.

Link copied to clipboard
abstract fun isDirectory(): Boolean

测试此抽象路径名表示的文件是否为目录.

Link copied to clipboard
abstract fun isFile(): Boolean

测试此抽象路径名表示的文件是否为普通文件.

Link copied to clipboard
abstract fun mkdirs(): Boolean

创建此抽象路径名命名的目录, 包括任何必需但不存在的父目录.

Link copied to clipboard
abstract fun readBytes(): ByteArray

将此文件的全部内容作为字节数组获取.

Link copied to clipboard
abstract fun readLines(charset: String): List<String>

将文件内容作为行列表读取.不要将此函数用于大文件.

Link copied to clipboard
abstract fun readText(charset: String): String

使用指定的字符集将此文件的全部内容作为字符串获取.

Link copied to clipboard
abstract fun renameTo(dest: ScriptFile): Boolean

重命名此抽象路径名表示的文件.

Link copied to clipboard
abstract fun writeBytes(byteArray: ByteArray)

将此文件的内容设置为字节数组. 如果此文件已存在, 它将被覆盖.

Link copied to clipboard
abstract fun writeText(text: String, charset: String)

将此文件的内容设置为使用指定字符集编码的文本. 如果此文件存在, 它将被覆盖.