这是源代码:[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)