All Downloads are FREE. Search and download functionalities are using the official Maven repository.

application.FileOperations.kt Maven / Gradle / Ivy

There is a newer version: 1.3.39
Show newest version
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
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy