Skip to content

Instantly share code, notes, and snippets.

@Allan-Gong
Created December 5, 2018 04:28
Show Gist options
  • Save Allan-Gong/2280eba13a72b3559725608b54b27876 to your computer and use it in GitHub Desktop.
Save Allan-Gong/2280eba13a72b3559725608b54b27876 to your computer and use it in GitHub Desktop.
private def logTempDiskSpace() = {
val tempDirectory = new File(System.getProperty("java.io.tmpdir"))
val tempDirectoryPath = tempDirectory.getCanonicalPath
val tempDirectorySize = FileUtils.byteCountToDisplaySize(FileUtils.sizeOfDirectory(tempDirectory))
logger.debug(s"Temp directory [$tempDirectoryPath] with size $tempDirectorySize")
tempDirectory.listFiles().toList.foreach(file => {
if (file.isDirectory) {
val directorySize = FileUtils.byteCountToDisplaySize(FileUtils.sizeOfDirectory(file))
logger.debug(s"${file.getName} - $directorySize")
} else {
val fileSize = FileUtils.byteCountToDisplaySize(file.length())
logger.debug(s"${file.getName} - $fileSize")
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment