{"record":{"id":"c01ae35778e857c3","repo":"stanfordnlp/CoreNLP","slug":"argstoproperties-could-not-read-properties-file","errorCode":null,"errorMessage":"argsToProperties could not read properties file: \" + file","messagePattern":"argsToProperties could not read properties file: \" \\+ file","errorType":"exception","errorClass":"RuntimeIOException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/util/StringUtils.java","lineNumber":1060,"sourceCode":"    /* Processing in reverse order, add properties that aren't present only. Thus, later ones override earlier ones. */\n    while (result.containsKey(PROPERTIES)) {\n      String file = result.getProperty(PROPERTIES);\n      if (LanguageInfo.isStanfordCoreNLPSupportedLang(file))\n              file = LanguageInfo.getLanguagePropertiesFile(file);\n      result.remove(PROPERTIES);\n      Properties toAdd = new Properties();\n      BufferedReader reader = null;\n      try {\n        reader = IOUtils.readerFromString(file);\n        toAdd.load(reader);\n        // trim all values\n        for (String propKey : toAdd.stringPropertyNames()) {\n          String newVal = toAdd.getProperty(propKey);\n          toAdd.setProperty(propKey, newVal.trim());\n        }\n      } catch (IOException e) {\n        String msg = \"argsToProperties could not read properties file: \" + file;\n        throw new RuntimeIOException(msg, e);\n      } finally {\n        IOUtils.closeIgnoringExceptions(reader);\n      }\n\n      for (String key : toAdd.stringPropertyNames()) {\n        String val = toAdd.getProperty(key);\n        if ( ! result.containsKey(key)) {\n          result.setProperty(key, val);\n        }\n      }\n    }\n\n    return result;\n  }\n\n\n  /**\n   * This method reads in properties listed in a file in the format prop=value, one property per line.","sourceCodeStart":1042,"sourceCodeEnd":1078,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/util/StringUtils.java#L1042-L1078","documentation":"When argsToProperties is given a filename (an argument beginning with a recognized file indicator) it tries to load that file as a Java properties file. If reading the file raises an IOException, the method rethrows it as RuntimeIOException('argsToProperties could not read properties file: <file>').","triggerScenarios":"Calling StringUtils.argsToProperties(args) (or the overload with a flags map) where the command line contains a filename argument and the file cannot be read: it doesn't exist, path is wrong, or I/O permissions block it.","commonSituations":"Command-line runs like '-props myprops.properties' with a typo'd or missing path; running from a different working directory with a relative path; missing read permissions in a cluster/CI environment.","solutions":["Verify the file path is correct and the file exists at the given (absolute or relative) location","Pass an absolute path or run the program from the directory containing the properties file","Check file read permissions for the user running the JVM","Inspect the cause (getCause()) of the RuntimeIOException for the underlying IOException"],"exampleFix":"// before\njava -cp ... Main -props confg.properties   // typo in filename\n// after\njava -cp ... Main -props /full/path/to/config.properties","handlingStrategy":"try-catch","validationCode":"File f = new File(filename);\nif (!f.isFile() || !f.canRead()) throw new IllegalStateException(\"Cannot read props file: \" + f.getAbsolutePath());","typeGuard":null,"tryCatchPattern":"try {\n  Properties props = StringUtils.argsToProperties(args);\n} catch (RuntimeIOException e) {\n  log.fatal(\"Properties file unreadable: \" + e.getMessage(), e.getCause());\n  System.exit(1);\n}","preventionTips":["Use absolute paths for -props arguments in scripts and CI","Check file existence/readability at startup before the library loads it","If the file is a classpath resource, load it via getResourceAsStream instead"],"tags":["java","io","properties","command-line"],"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-16T04:17:20.429Z"}