Name: dbT83986 Date: 02/25/99
/*
This method works correctly if fileName is a file in the current
directory. But bytes is always 1 if fileName is a file in a jar
*/
public byte[] receiveBytes(String fileName) throws Exception {
InputStream inputStream = null;
byte[] data = null;
try {
inputStream = getClass().getResourceAsStream("/" + fileName);
int bytes = inputStream.available();
data = new byte[bytes];
inputStream.read(data);
System.out.println("LoadFile.receiveBytes: fileName="+fileName+" user.dir="+System.getProperty("user.dir")+" bytes="+bytes);
} finally {
if(inputStream != null)
inputStream.close();
}
return data;
}
(Review ID: 48227)
======================================================================
- duplicates
-
JDK-4200501 getResourceAsStream returns poor InputStream
-
- Closed
-