{"record":{"id":"2bc7c8ae3f24584c","repo":"stanfordnlp/CoreNLP","slug":"filesystem-error-copying-s-to-s-n","errorCode":null,"errorMessage":"FileSystem: Error copying %s to %s%n","messagePattern":"FileSystem: Error copying (.+?) to (.+?)%n","errorType":"exception","errorClass":"RuntimeIOException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/io/FileSystem.java","lineNumber":47,"sourceCode":"   * @param sourceFile The file to copy.\n   * @param destFile The path to copy to which the file should be copied.\n   * @throws RuntimeIOException If any IO problem\n   */\n  @SuppressWarnings(\"ResultOfMethodCallIgnored\")\n  public static void copyFile(File sourceFile, File destFile) {\n    try {\n      if (!destFile.exists()) {\n        destFile.createNewFile();\n      }\n    } catch (IOException ioe) {\n      throw new RuntimeIOException(ioe);\n    }\n\n    try (FileChannel source = new FileInputStream(sourceFile).getChannel();\n         FileChannel destination = new FileOutputStream(destFile).getChannel()) {\n      destination.transferFrom(source, 0, source.size());\n    } catch (IOException e) {\n      throw new RuntimeIOException(String.format(\"FileSystem: Error copying %s to %s%n\",\n              sourceFile.getPath(), destFile.getPath()), e);\n    }\n  }\n\n  /**\n   * Similar to the unix gzip command, only it does not delete the file after compressing it.\n   * \n   * @param uncompressedFileName The file to gzip\n   * @param compressedFileName The file name for the compressed file\n   * @throws IOException\n   */\n  public static void gzipFile(File uncompressedFileName, File compressedFileName) throws IOException {\n    try (GZIPOutputStream out = new GZIPOutputStream(new FileOutputStream(compressedFileName));\n         FileInputStream in = new FileInputStream(uncompressedFileName)) {\n      byte[] buf = new byte[1024];\n      for (int len; (len = in.read(buf)) > 0; ) {\n        out.write(buf, 0, len);\n      }","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/io/FileSystem.java#L29-L65","documentation":"RuntimeIOException from FileSystem.copyFile when an IOException occurs while creating the destination file or copying channels from source to destination — e.g., missing source, unwritable destination, or disk full.","triggerScenarios":"Calling FileSystem.copyFile(src, dst) when the source cannot be opened (missing/no permission), the destination cannot be created (bad path, no permission, is a directory), or the channel transfer fails mid-copy (disk full, device error).","commonSituations":"Disk quota exceeded on large files; destination directory doesn't exist; source locked or removed; cross-filesystem copy on a full mount.","solutions":["Verify destination parent directory exists and is writable; create it with FileSystem.mkdirOrFail if needed.","Check the source file exists and is readable.","Free disk space / check quota on the destination volume.","Inspect the wrapped IOException cause for the precise OS error and address it (permissions, ENOSPC, etc.)."],"exampleFix":"// before\nFileSystem.copyFile(src, new File(\"/out/copy.bin\")); // /out missing\n// after\nFile dst = new File(\"/out/copy.bin\");\nFileSystem.mkdirOrFail(dst.getParentFile());\nFileSystem.copyFile(src, dst);","handlingStrategy":"try-catch","validationCode":"if (!src.exists() || !src.canRead()) throw new IllegalStateException(\"Bad source: \" + src);\nFile parent = dst.getParentFile();\nif (parent != null && !parent.isDirectory()) FileSystem.mkdirOrFail(parent);\nif (dst.exists() && dst.isDirectory()) throw new IllegalStateException(\"Dst is a dir: \" + dst);","typeGuard":null,"tryCatchPattern":"try {\n  FileSystem.copyFile(src, dst);\n} catch (RuntimeIOException e) {\n  log.severe(\"Copy failed: \" + e.getMessage() + \" cause=\" + e.getCause());\n}","preventionTips":["Ensure destination parent directory exists","Check free disk space for large copies","Keep source files readable and not deleted mid-copy"],"tags":["file-io","ioexception","copy"],"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-17T15:17:12.973Z"}