日期:2014-05-20  浏览次数:21619 次

请问: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)