{"record":{"id":"766cbe8a06916aa7","repo":"stanfordnlp/CoreNLP","slug":"edu-stanford-nlp-io-runtimeioexception","errorCode":null,"errorMessage":"edu.stanford.nlp.io.RuntimeIOException","messagePattern":"edu\\.stanford\\.nlp\\.io\\.RuntimeIOException","errorType":"exception","errorClass":"RuntimeIOException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/classify/RVFDataset.java","lineNumber":765,"sourceCode":"      }\n    }\n  }\n\n  private static RVFDataset<String, String> readSVMLightFormat(String filename, Index<String> featureIndex, Index<String> labelIndex, List<String> lines) {\n    BufferedReader in = null;\n    RVFDataset<String, String> dataset;\n    try {\n      dataset = new RVFDataset<>(10, featureIndex, labelIndex);\n      in = IOUtils.readerFromString(filename);\n\n      while (in.ready()) {\n        String line = in.readLine();\n        if (lines != null)\n          lines.add(line);\n        dataset.add(svmLightLineToRVFDatum(line));\n      }\n    } catch (IOException e) {\n      throw new RuntimeIOException(e);\n    } finally {\n      IOUtils.closeIgnoringExceptions(in);\n    }\n    return dataset;\n  }\n\n  public static RVFDatum<String, String> svmLightLineToRVFDatum(String l) {\n    l = l.replaceFirst(\"#.*$\", \"\"); // remove any trailing comments\n    String[] line = l.split(\"\\\\s+\");\n    ClassicCounter<String> features = new ClassicCounter<>();\n    for (int i = 1; i < line.length; i++) {\n      String[] f = line[i].split(\":\");\n      if (f.length != 2) {\n        throw new IllegalArgumentException(\"Bad data format: \" + l);\n      }\n      double val = Double.parseDouble(f[1]);\n      features.incrementCount(f[0], val);\n    }","sourceCodeStart":747,"sourceCodeEnd":783,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/classify/RVFDataset.java#L747-L783","documentation":"RVFDataset.readSVMLightFormat (constructor/static reader) reads an SVM-light formatted file line by line; if a BufferedReader IOException occurs mid-read it wraps and rethrows it as edu.stanford.nlp.io.RuntimeIOException so callers of the constructor don't need checked exception handling. It indicates the input file could not be read completely (I/O failure, not a format problem).","triggerScenarios":"Calling the RVFDataset constructor / readSVMLightFormat with a filename whose file exists but whose stream fails during reading: disk error, file deleted mid-read, stream closed early, or permission/encoding issues at read time.","commonSituations":"Reading files from network mounts that drop connections; files truncated or locked by another process; running in containers with restricted filesystems where opening succeeds but reads fail.","solutions":["Check the file is on a readable local filesystem and not being modified while reading","Catch RuntimeIOException around the read call and inspect the cause (getCause() returns the original IOException) for the real problem","Verify file permissions and that enough disk/memory are available","Retry or re-copy the source file if the medium (network share, USB) is flaky"],"exampleFix":"// before\nRVFDataset<String,String> ds = new RVFDataset<>(\"data.svmlight\", -1);\n// after\ntry {\n  RVFDataset<String,String> ds = new RVFDataset<>(\"data.svmlight\", -1);\n} catch (RuntimeIOException e) {\n  logger.severe(\"Failed reading data.svmlight: \" + e.getCause());\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"File f = new File(path);\nif (!f.isFile()) throw new FileNotFoundException(path);\nif (!f.canRead()) throw new IOException(\"No read permission: \" + path);","typeGuard":null,"tryCatchPattern":"try {\n  RVFDataset<String,String> ds = new RVFDataset<>(path, -1);\n} catch (RuntimeIOException e) {\n  throw new RuntimeException(\"Could not read SVM-light file: \" + path + \" (cause: \" + e.getCause() + \")\", e);\n}","preventionTips":["Read from stable local storage, not network shares, for large datasets","Never modify/delete the data file while training is reading it","Always check e.getCause() for the underlying IOException"],"tags":["java","stanford-nlp","io","file-read"],"backgroundTag":"file-read-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"}