int bytesread = 0;
int retval;
InputStream inputStream =
getMostSpecificStream(key, language, country, variant);
if (inputStream == null)
throw new MissingResourceException(
"Key '" + key
+ "' is present in .properties file with no value, yet "
+ "text file resource is missing",
RefCapablePropertyResourceBundle.class.getName(), key);
try {
try {
ba = new byte[inputStream.available()];
} catch (RuntimeException re) {
throw new MissingResourceException(
"Resource is too big to read in '" + key + "' value in one "
+ "gulp.\nPlease run the program with more RAM "
+ "(try Java -Xm* switches).: " + re,
RefCapablePropertyResourceBundle.class.getName(), key);
} catch (IOException ioe) {
throw new MissingResourceException(
"Failed to read in value for key '" + key + "': " + ioe,
RefCapablePropertyResourceBundle.class.getName(), key);
}
try {
while (bytesread < ba.length &&
(retval = inputStream.read(
ba, bytesread, ba.length - bytesread)) > 0) {
bytesread += retval;
}
} catch (IOException ioe) {
throw new MissingResourceException(
"Failed to read in value for '" + key + "': " + ioe,
RefCapablePropertyResourceBundle.class.getName(), key);
}
} finally {
try {
inputStream.close();
} catch (IOException ioe) {
System.err.println("Failed to close input stream: " + ioe);
}
}
if (bytesread != ba.length) {
throw new MissingResourceException(
"Didn't read all bytes. Read in "
+ bytesread + " bytes out of " + ba.length
+ " bytes for key '" + key + "'",
RefCapablePropertyResourceBundle.class.getName(), key);
}
try {
return new String(ba, "ISO-8859-1");
} catch (UnsupportedEncodingException uee) {
throw new RuntimeException(uee);
} catch (RuntimeException re) {
throw new MissingResourceException(
"Value for key '" + key + "' too big to convert to String. "
+ "Please run the program with more RAM "
+ "(try Java -Xm* switches).: " + re,
RefCapablePropertyResourceBundle.class.getName(), key);
}