← Back to all projects

FileUtils

Skript

SkriptLibraryUtilityskript-reflect

A reusable Skript file I/O library backed by skript-reflect (java.nio.file): exists, create, append, and read files, plus related helpers.

Download

FileUtils is a small Skript library of reusable file read/write functions that I wrote for skript-reflect, using Java’s java.nio.file API. It replaces the old skUtilities file syntax used by scripts like ChatControl.

Requirement: skript-reflect 2.6.3+

Functions

fileExists(path: text) :: boolean
fileEnsure(path: text)
fileAppend(path: text, content: text)
fileLineCount(path: text) :: integer
fileReadLines(path: text) :: texts
fileLine(path: text, line: integer) :: text

All functions are 1-indexed and create parent directories / the file itself as needed, so you can append to a log file without worrying about setup:

fileAppend("plugins/Skript/scripts/ChatControl/messages.log", "(Message Time: %now%) %player%: %message%")

Why it exists

Scripts like ChatControl used to depend on the third-party skUtilities addon just for file operations. FileUtils provides the same features with only skript-reflect, so chatcontrol.sk no longer needs skUtilities.