application.FileOperations.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of specmatic-executable Show documentation
Show all versions of specmatic-executable Show documentation
Command-line standalone executable jar for Specmatic
package application
import org.springframework.stereotype.Component
import java.io.File
@Component
class FileOperations {
fun read(path: String): String {
return File(path).readText()
}
fun readBytes(path: String): ByteArray {
return File(path).readBytes()
}
fun files(stubDataDir: String): List {
return File(stubDataDir).listFiles()?.toList() ?: emptyList()
}
fun isFile(fileName: String): Boolean = File(fileName).isFile
fun isDirectory(fileName: String): Boolean = File(fileName).isDirectory
fun isJSONFile(file: File): Boolean =
file.isFile && file.extension.equals("json", ignoreCase = true)
fun extensionIsNot(fileName: String, extensions: List): Boolean = File(fileName).extension !in extensions
}