Java – how do I find file sizes in scala?
•
Java
I'm writing a Scala script and need to know the size of a file How to execute correctly?
os.stat('somefile.txt').st_size
And scala?
Solution
There is no way to use the scala standard library Instead of using external libraries, you can use java file The length () method does this In Scala, this would be:
val someFile = new File("somefile.txt") val fileSize = someFile.length
If you want a specific Scala, you can use something like scalax IO or capture IO such an external framework
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码