package cn.flightfeather.supervision.infrastructure.utils
|
|
import java.io.File
|
import java.io.FileOutputStream
|
|
|
class FileUtil {
|
@Throws(Exception::class)
|
fun uploadFile(file: ByteArray, filePath: String, fileName: String) {
|
val targetFile = File(filePath)
|
if (!targetFile.exists()) {
|
targetFile.mkdirs()
|
}
|
val out = FileOutputStream(filePath + fileName)
|
out.write(file)
|
out.flush()
|
out.close()
|
}
|
|
/**
|
* 获取文件名
|
*/
|
fun getFileName(path: String?): String {
|
if (!path.isNullOrEmpty()) {
|
val dot = path!!.lastIndexOf('/')
|
if (dot > -1 && dot < path.length - 1) {
|
return path.substring(dot + 1)
|
}
|
}
|
return ""
|
}
|
}
|