当前位置: 代码迷 >> J2SE >> java.io.IOException: Bad file descriptor
  详细解决方案

java.io.IOException: Bad file descriptor

热度:700   发布时间:2016-04-24 13:06:47.0
请问:bad file descriptor是什么错误?
这是源代码:[code=Java]import java.io.*;
public class FileTest2{
public static void main(String[] args){
FileOutputStream fos = null ;
try{
fos = new FileOutputStream("F:\\java_ex\\abc.txt");
}catch(FileNotFoundException fnf){
fnf.printStackTrace();
}
for(int i='A';i<'Z';i++){
try{
fos.write(i);
fos.close();
}catch(IOException ioe){
ioe.printStackTrace();
}
}
}
}[/code]
这是错误提示:
F:\java_ex>javac FileTest2.java

F:\java_ex>java FileTest
java.io.IOException: Bad file descriptor
  at java.io.FileOutputStream.write(Native Method)
  at FileTest.main(FileTest.java:38)
java.io.IOException: Bad file descriptor
  at java.io.FileOutputStream.write(Native Method)
  at FileTest.main(FileTest.java:38)
java.io.IOException: Bad file descriptor
  at java.io.FileOutputStream.write(Native Method)
  at FileTest.main(FileTest.java:38)
java.io.IOException: Bad file descriptor
  at java.io.FileOutputStream.write(Native Method)
  at FileTest.main(FileTest.java:38)
java.io.IOException: Bad file descriptor
  at java.io.FileOutputStream.write(Native Method)
  at FileTest.main(FileTest.java:38)
java.io.IOException: Bad file descriptor
  at java.io.FileOutputStream.write(Native Method)
  at FileTest.main(FileTest.java:38)
java.io.IOException: Bad file descriptor
  at java.io.FileOutputStream.write(Native Method)
  at FileTest.main(FileTest.java:38)
java.io.IOException: Bad file descriptor
  at java.io.FileOutputStream.write(Native Method)
  at FileTest.main(FileTest.java:38)
java.io.IOException: Bad file descriptor
  at java.io.FileOutputStream.write(Native Method)
  at FileTest.main(FileTest.java:38)
java.io.IOException: Bad file descriptor
  at java.io.FileOutputStream.write(Native Method)
  at FileTest.main(FileTest.java:38)
java.io.IOException: Bad file descriptor
  at java.io.FileOutputStream.write(Native Method)
  at FileTest.main(FileTest.java:38)
java.io.IOException: Bad file descriptor
  at java.io.FileOutputStream.write(Native Method)
  at FileTest.main(FileTest.java:38)
java.io.IOException: Bad file descriptor
  at java.io.FileOutputStream.write(Native Method)
  at FileTest.main(FileTest.java:38)
java.io.IOException: Bad file descriptor
  at java.io.FileOutputStream.write(Native Method)
  at FileTest.main(FileTest.java:38)
java.io.IOException: Bad file descriptor
  at java.io.FileOutputStream.write(Native Method)
  at FileTest.main(FileTest.java:38)
java.io.IOException: Bad file descriptor
  at java.io.FileOutputStream.write(Native Method)
  at FileTest.main(FileTest.java:38)
java.io.IOException: Bad file descriptor
  at java.io.FileOutputStream.write(Native Method)
  at FileTest.main(FileTest.java:38)
java.io.IOException: Bad file descriptor
  at java.io.FileOutputStream.write(Native Method)
  at FileTest.main(FileTest.java:38)
java.io.IOException: Bad file descriptor
  at java.io.FileOutputStream.write(Native Method)
  at FileTest.main(FileTest.java:38)
java.io.IOException: Bad file descriptor
  at java.io.FileOutputStream.write(Native Method)
  at FileTest.main(FileTest.java:38)
java.io.IOException: Bad file descriptor
  at java.io.FileOutputStream.write(Native Method)
  相关解决方案