fOpen
Opens the File, closing it automatically once block completes.
NOTE: Calling fclose on FILE within block will result in an IOException being thrown on block closure. Do not call fclose; it is handled on completion.
NOTE: Flag e
for O_CLOEXEC is always added to flags for non-Windows if it is not present.
e.g.
myFile.withOpen("rb") { file ->
// read it
}
Content copied to clipboard
Parameters
flags
fopen arguments (e.g. "rb", "ab", "wb")
Throws
on fopen/fclose failure. Note that any exceptions thrown by block will not be converted to an IOException.