I'm getting java.io.IOException: write failed: EBADF (Bad file descriptor)
when trying to write a RandomAccessFile
.
RandomAccessFile raf;
try {
raf = new RandomAccessFile("foo", "r");
byte bytes[] = "test".getBytes(StandardCharsets.US_ASCII);
raf.write(bytes);
raf.close();
} catch (FileNotFoundException e){
} catch (IOException e){
}
Why do I get this exception?
创建RandomAccessFile
时使用“rw”而不是“r”。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.