![](/img/trans.png)
[英]SocketException: sendto failed: EBADF (Bad file descriptor)
[英]RandomAccessFile.write: EBADF (Bad file descriptor)
我在嘗試編寫RandomAccessFile
時收到java.io.IOException: write failed: EBADF (Bad file descriptor)
。
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){
}
為什么我會收到此異常?
創建RandomAccessFile
時使用“rw”而不是“r”。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.