stanfordnlp/CoreNLP · error · RuntimeIOException
propFileToProperties could not read properties file: " +…
Error message
propFileToProperties could not read properties file: " + filename
What it means
StringUtils.propFileToProperties loads a properties file from disk. If the load throws IOException, it is rethrown as RuntimeIOException('propFileToProperties could not read properties file: <filename>'), indicating the file could not be opened or read.
Solutions
- Confirm the filename/path exists and is readable before calling (new File(filename).canRead())
- Use an absolute path or resolve the path relative to a known base directory
- If the file is a classpath resource, load it via getResourceAsStream instead of propFileToProperties
Example fix
// before
Properties p = StringUtils.propFileToProperties("config.properties"); // not in cwd
// after
File f = new File("config.properties");
if (!f.canRead()) throw new IllegalStateException("Missing config: " + f.getAbsolutePath());
Properties p = StringUtils.propFileToProperties(f.getAbsolutePath()); Defensive patterns
Strategy: validation
Validate before calling
File f = new File(filename);
if (!f.isFile() || !f.canRead()) throw new IllegalStateException("Missing properties file: " + f.getAbsolutePath()); Try / catch
try {
Properties p = StringUtils.propFileToProperties(filename);
} catch (RuntimeIOException e) {
log.error("Cannot load properties: " + e.getMessage());
p = new Properties(); // or abort
} Prevention
- Ship a default config and verify its presence at startup
- Resolve config paths relative to a known base or environment variable
- For bundled resources, read via the classpath rather than the filesystem
When it happens
Trigger: Calling StringUtils.propFileToProperties(filename) with a path that does not exist, is a directory, or cannot be read due to permissions or I/O errors.
Common situations: Config file not shipped with the application; relative path resolved against an unexpected working directory; file deleted between check and read in CI; wrong resource path when intending to load from the classpath instead of the filesystem.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- Error reading threshold file
- IOException reading CEDict from file
- argsToProperties could not read properties file: " + file
- Error loading classifier from
- edu.stanford.nlp.io.RuntimeIOException
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/9c28ec7cfddf4ed1.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/util/StringUtils.java:1098
* something not implemented in the {@code load()} method.
*
* @param filename A properties file to read
* @return The corresponding Properties object
*/
public static Properties propFileToProperties(String filename) {
try {
InputStream is = new BufferedInputStream(new FileInputStream(filename));
Properties result = new Properties();
result.load(is);
// trim all values
for (String propKey : result.stringPropertyNames()){
String newVal = result.getProperty(propKey);
result.setProperty(propKey,newVal.trim());
}
is.close();
return result;
} catch (IOException e) {
throw new RuntimeIOException("propFileToProperties could not read properties file: " + filename, e);
}
}
/**
* This method converts a comma-separated String (with whitespace
* optionally allowed after the comma) representing properties
* to a Properties object. Each property is "property=value". The value
* for properties without an explicitly given value is set to "true". This can be used for a 2nd level
* of properties, for example, when you have a commandline argument like "-outputOptions style=xml,tags".
*/
public static Properties stringToProperties(String str) {
Properties result = new Properties();
return stringToProperties(str, result);
}
/**
* This method updates a Properties object based on
* a comma-separated String (with whitespaceView on GitHub (pinned to 1b7edd19c4)