{"record":{"id":"d2cdb5e898d33780","repo":"stanfordnlp/CoreNLP","slug":"java-io-ioexception-d2cdb5","errorCode":null,"errorMessage":"java.io.IOException","messagePattern":"java\\.io\\.IOException","errorType":"exception","errorClass":"RuntimeIOException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/process/stattok/StatTokSent.java","lineNumber":73,"sourceCode":"\n  public static final String SENTINEL = \"\\u00A7\";\n\n  /**\n   * This is the constructor for the StatTokSent object.\n   * Parameters:\n   * \tmodelFile: a string containing the path to the model;\n   * \tmultiWordRulesFile: a string containing the path to the file with multi-word tokens.\n   */\n  public StatTokSent(String modelFile, String multiWordRulesFile) {\n    logger.info(\"Loading StatTokSent model from \" + modelFile);\n    if (multiWordRulesFile == null) {\n      logger.info(\"Using default multi word rules\");\n    } else {\n      logger.info(\"Using multi word rules from \" + multiWordRulesFile);\n      try {\n        multiWordRules = this.readMultiWordRules(multiWordRulesFile);\n      } catch (IOException e) {\n        throw new RuntimeIOException(e);\n      }\n    }\n\n    ObjectInputStream ois;\n\n    try {\n      ois = IOUtils.readStreamFromString(modelFile);\n      cdc = ColumnDataClassifier.getClassifier(ois);\n      this.windowSize = ois.readInt();\n    } catch (IOException e) {\n      throw new RuntimeIOException(e);\n    } catch (ClassNotFoundException e) {\n      throw new RuntimeClassNotFoundException(e);\n    }\n\n    logger.info(\"Found window size of \" + this.windowSize);\n  }\n","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/process/stattok/StatTokSent.java#L55-L91","documentation":"The StatTokSent constructor loads multi-word tokenizer rules from a file if one is configured. If reading those rules throws IOException, it is wrapped in RuntimeIOException. This means the rules file could not be read (missing, unreadable, or IO error mid-read).","triggerScenarios":"Constructing StatTokSent with a multiWordRulesFile path that doesn't exist or can't be opened/read — readMultiWordRules failing on a bad path or IO problem.","commonSituations":"Wrong relative path to the multiWordRules file; file exists in the repo but not on the deployment classpath/filesystem; permissions issues; passing a resource name where a filesystem path is required.","solutions":["Verify the multiWordRulesFile path exists and is readable at runtime (new File(path).canRead())","Use an absolute path or resolve it against the classpath/resource and copy it out","Omit the multi-word rules file argument to use the built-in default rules","Run with the working directory you expect; relative paths resolve from CWD"],"exampleFix":"// before\nnew StatTokSent(modelFile, \"rules/multiword.tsv\"); // path missing on server\n// after\nString rules = locate(\"rules/multiword.tsv\"); // resolve from classpath or absolute path\nnew StatTokSent(modelFile, rules);","handlingStrategy":"validation","validationCode":"File f = new File(multiWordRulesFile);\nif (!f.isFile() || !f.canRead()) throw new IllegalStateException(\"multiWordRulesFile unreadable: \" + multiWordRulesFile);","typeGuard":null,"tryCatchPattern":"try {\n  new StatTokSent(modelFile, rulesFile);\n} catch (RuntimeIOException e) {\n  logger.warn(\"Rules file unreadable, using defaults\", e);\n  new StatTokSent(modelFile, null); // default multi word rules\n}","preventionTips":["Resolve rules files via classpath or absolute path at deployment","Ship rules files inside the artifact and extract to temp if needed","Check canRead() before constructing"],"tags":["java","io","file-not-found","tokenizer"],"backgroundTag":"file-not-found","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"}