stanfordnlp/CoreNLP · critical · RuntimeIOException
No input file provided (use -textFile)
Error message
No input file provided (use -textFile)
What it means
DependencyParser.test() wraps any IOException that occurs while opening the -textFile input source (file or stdin) in a RuntimeIOException with this message. The parser needs a readable text input to parse; if the file cannot be opened (missing, unreadable, bad path) the whole test run is aborted. The '(use -textFile)' hint points at the CLI flag that supplies the input.
Solutions
- Verify the -textFile path exists and is readable (ls -l) before running the parser.
- Run with an absolute path to eliminate working-directory confusion.
- Check file permissions / that it is a regular file, not a directory.
- Ensure the encoding matches the file's actual charset to avoid decode-time IO errors.
Example fix
// before java -cp stanford-corenlp.jar edu.stanford.nlp.parser.nndep.DependencyParser -textFile input.tx // after java -cp stanford-corenlp.jar edu.stanford.nlp.parser.nndep.DependencyParser -textFile /abs/path/input.txt
Defensive patterns
Strategy: validation
Validate before calling
java.io.File f = new java.io.File(textFilePath);
if (textFilePath == null || (!textFilePath.equals("-") && (!f.isFile() || !f.canRead())))
throw new IllegalArgumentException("Input text file missing or unreadable: " + textFilePath); Try / catch
try {
parser.test(argsToProps, "-textFile", path);
} catch (RuntimeIOException e) {
// check cause: input file open failure
} Prevention
- Resolve -textFile to an absolute path before invoking the parser.
- Check File.isFile() && canRead() in a preflight step.
- Remember "-" means stdin; pipe input explicitly when using it.
When it happens
Trigger: Running the parser test path with props 'testFile'/'textFile' pointing to a nonexistent path, a directory, or a file the process cannot read; also any IO error while opening stdin when inputFilename is "-".
Common situations: Typos in the -textFile path, running from a different working directory than expected, missing read permissions, or forgeting to specify -textFile at all so the default "-"/empty path fails.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Couldn't read function word file
- Error opening output file
- TokensRegexNERAnnotator
- Couldn't read TokensRegexNER from
- java.io.IOException
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/b3789a064d267ab6.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/parser/nndep/DependencyParser.java:1320
parser.testCoNLL(props.getProperty("testFile"), props.getProperty("outFile"));
}
// Parse raw text data
if (props.containsKey("textFile")) {
if (!loaded) {
parser.loadModelFile(props.getProperty("model"));
loaded = true;
}
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)