{"record":{"id":"2594c65459558701","repo":"stanfordnlp/CoreNLP","slug":"error-opening-output-file","errorCode":null,"errorMessage":"Error opening output file","messagePattern":"Error opening output file","errorType":"exception","errorClass":"RuntimeIOException","httpStatus":null,"severity":"critical","filePath":"src/edu/stanford/nlp/parser/nndep/DependencyParser.java","lineNumber":1330,"sourceCode":"      String encoding = parser.config.tlp.getEncoding();\n      String inputFilename = props.getProperty(\"textFile\");\n      BufferedReader input;\n      try {\n        input = inputFilename.equals(\"-\")\n                ? IOUtils.readerFromStdin(encoding)\n                : IOUtils.readerFromString(inputFilename, encoding);\n      } catch (IOException e) {\n        throw new RuntimeIOException(\"No input file provided (use -textFile)\", e);\n      }\n\n      String outputFilename = props.getProperty(\"outFile\");\n      PrintWriter output;\n      try {\n        output = outputFilename == null || outputFilename.equals(\"-\")\n            ? IOUtils.encodedOutputStreamPrintWriter(System.out, encoding, true)\n            : IOUtils.getPrintWriter(outputFilename, encoding);\n      } catch (IOException e) {\n        throw new RuntimeIOException(\"Error opening output file\", e);\n      }\n\n      parser.parseTextFile(input, output);\n    }\n  }\n\n}\n","sourceCodeStart":1312,"sourceCodeEnd":1338,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/parser/nndep/DependencyParser.java#L1312-L1338","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n-outFile /nonexistent/dir/parsed.conll\n// after\nmkdir -p /out && -outFile /out/parsed.conll","handlingStrategy":"validation","validationCode":"java.io.File out = new java.io.File(outFilePath);\nif (outFilePath != null && !outFilePath.equals(\"-\")) {\n    java.io.File parent = out.getAbsoluteFile().getParentFile();\n    if (parent == null || !parent.isDirectory() || !parent.canWrite())\n        throw new IllegalArgumentException(\"Output directory missing or unwritable: \" + parent);\n}","typeGuard":null,"tryCatchPattern":"try {\n    parser.test(props, \"-textFile\", in, \"-outFile\", out);\n} catch (RuntimeIOException e) {\n    // inspect cause: output file open failure\n}","preventionTips":["Create the output parent directory (mkdirs) before running.","Verify write permission for the process user.","Drop -outFile and redirect stdout when unsure."],"tags":["java","io","file-write","nlp"],"backgroundTag":"file-write-failed","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}