Truncate a file: Difference between revisions

(Added Bracmat example)
Line 678:
# Truncate a file to 567 bytes.
File.truncate("file", 567)</lang>
 
=={{header|Scala}}==
[[Category:Scala Implementations]]
{{libheader|Scala}}<lang Scala>import java.io.FileOutputStream
 
object TruncFile extends App {
if (args.length < 2) println("Usage: java TruncFile fileName newSize")
else { //turn on "append" so it doesn't clear the file
val outChan = new FileOutputStream(args(0), true).getChannel()
val newSize = args(1).toLong
outChan.truncate(newSize)
}
}</lang>
 
=={{header|Tcl}}==
Anonymous user