我从资源中获取输入流,如下所示:
InputStream is = clazz.getClassLoader().getResourceAsStream(resourcePath);
最终,这个输入流被包装在 InputStreamReader 中,并且阅读器与 java.io.LineNumberReader 一起用于从 CSV 文件中读取行。
该代码可在 Tomcat 上运行,但是当我在 JBoss 5.1.0 GA 应用服务器上运行该代码时,会出现以下异常:
Caused by: java.io.IOException: Bad file descriptor
at java.io.FileInputStream.readBytes(Native Method)
at java.io.FileInputStream.read(FileInputStream.java:220)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158)
at java.io.InputStreamReader.read(InputStreamReader.java:167)
at java.io.BufferedReader.fill(BufferedReader.java:136)
at java.io.BufferedReader.readLine(BufferedReader.java:299)
at java.io.LineNumberReader.readLine(LineNumberReader.java:182)
Caused by: java.io.IOException: Read error
at java.io.FileInputStream.readBytes(Native Method)
at java.io.FileInputStream.read(FileInputStream.java:220)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158)
at java.io.InputStreamReader.read(InputStreamReader.java:167)
at java.io.BufferedReader.fill(BufferedReader.java:136)
at java.io.BufferedReader.readLine(BufferedReader.java:299)
at java.io.LineNumberReader.readLine(LineNumberReader.java:182)
有谁知道为什么这适用于 Tomcat 而不适用于 JBoss?