stanfordnlp/CoreNLP · critical · RuntimeIOException
Error opening output file
Error message
Error opening output file
What it means
DependencyParser.test() wraps any IOException from opening the output writer (a file via 'outFile' or stdout) in a RuntimeIOException with this message. If the parser cannot open the destination for parse results, the test run aborts before parsing begins.
Solutions
- Create the output file's parent directory before running (mkdir -p).
- Ensure the output path points to a writable regular file, not a directory.
- Check write permissions on the target directory/user.
- Omit -outFile to write to stdout and redirect output yourself.
Example fix
// before -outFile /nonexistent/dir/parsed.conll // after mkdir -p /out && -outFile /out/parsed.conll
Defensive patterns
Strategy: validation
Validate before calling
java.io.File out = new java.io.File(outFilePath);
if (outFilePath != null && !outFilePath.equals("-")) {
java.io.File parent = out.getAbsoluteFile().getParentFile();
if (parent == null || !parent.isDirectory() || !parent.canWrite())
throw new IllegalArgumentException("Output directory missing or unwritable: " + parent);
} Try / catch
try {
parser.test(props, "-textFile", in, "-outFile", out);
} catch (RuntimeIOException e) {
// inspect cause: output file open failure
} Prevention
- Create the output parent directory (mkdirs) before running.
- Verify write permission for the process user.
- Drop -outFile and redirect stdout when unsure.
When it happens
Trigger: Setting the outFile property/-outFile flag to a path in a nonexistent directory, a read-only location, or one requiring permissions the process lacks; an IO error while wrapping System.out.
Common situations: Output directory does not exist, output path is a directory rather than a file, disk is full or read-only mount, running under a user without write permission.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- Error creating data exporter
- Serializing classifier to
- No input file provided (use -textFile)
- RuntimeIOException wrapping IOException from write
- Exception in printToFile " + file.getAbsolutePath()
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/2594c65459558701.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/parser/nndep/DependencyParser.java:1330
String encoding = parser.config.tlp.getEncoding();
String inputFilename = props.getProperty("textFile");
BufferedReader input;
try {
input = inputFilename.equals("-")
? IOUtils.readerFromStdin(encoding)
: IOUtils.readerFromString(inputFilename, encoding);
} catch (IOException e) {
throw new RuntimeIOException("No input file provided (use -textFile)", e);
}
String outputFilename = props.getProperty("outFile");
PrintWriter output;
try {
output = outputFilename == null || outputFilename.equals("-")
? IOUtils.encodedOutputStreamPrintWriter(System.out, encoding, true)
: IOUtils.getPrintWriter(outputFilename, encoding);
} catch (IOException e) {
throw new RuntimeIOException("Error opening output file", e);
}
parser.parseTextFile(input, output);
}
}
}
View on GitHub (pinned to 1b7edd19c4)