stanfordnlp/CoreNLP · error · RuntimeIOException

FileSystem: Error copying

Error message

FileSystem: Error copying %s to %s%n

What it means

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.

Solutions

  1. Verify destination parent directory exists and is writable; create it with FileSystem.mkdirOrFail if needed.
  2. Check the source file exists and is readable.
  3. Free disk space / check quota on the destination volume.
  4. Inspect the wrapped IOException cause for the precise OS error and address it (permissions, ENOSPC, etc.).

Example fix

// before
FileSystem.copyFile(src, new File("/out/copy.bin")); // /out missing
// after
File dst = new File("/out/copy.bin");
FileSystem.mkdirOrFail(dst.getParentFile());
FileSystem.copyFile(src, dst);
Defensive patterns

Strategy: try-catch

Validate before calling

if (!src.exists() || !src.canRead()) throw new IllegalStateException("Bad source: " + src);
File parent = dst.getParentFile();
if (parent != null && !parent.isDirectory()) FileSystem.mkdirOrFail(parent);
if (dst.exists() && dst.isDirectory()) throw new IllegalStateException("Dst is a dir: " + dst);

Try / catch

try {
  FileSystem.copyFile(src, dst);
} catch (RuntimeIOException e) {
  log.severe("Copy failed: " + e.getMessage() + " cause=" + e.getCause());
}

Prevention

When it happens

Trigger: 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).

Common situations: Disk quota exceeded on large files; destination directory doesn't exist; source locked or removed; cross-filesystem copy on a full mount.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/2bc7c8ae3f24584c. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/io/FileSystem.java:47

   * @param sourceFile The file to copy.
   * @param destFile The path to copy to which the file should be copied.
   * @throws RuntimeIOException If any IO problem
   */
  @SuppressWarnings("ResultOfMethodCallIgnored")
  public static void copyFile(File sourceFile, File destFile) {
    try {
      if (!destFile.exists()) {
        destFile.createNewFile();
      }
    } catch (IOException ioe) {
      throw new RuntimeIOException(ioe);
    }

    try (FileChannel source = new FileInputStream(sourceFile).getChannel();
         FileChannel destination = new FileOutputStream(destFile).getChannel()) {
      destination.transferFrom(source, 0, source.size());
    } catch (IOException e) {
      throw new RuntimeIOException(String.format("FileSystem: Error copying %s to %s%n",
              sourceFile.getPath(), destFile.getPath()), e);
    }
  }

  /**
   * Similar to the unix gzip command, only it does not delete the file after compressing it.
   * 
   * @param uncompressedFileName The file to gzip
   * @param compressedFileName The file name for the compressed file
   * @throws IOException
   */
  public static void gzipFile(File uncompressedFileName, File compressedFileName) throws IOException {
    try (GZIPOutputStream out = new GZIPOutputStream(new FileOutputStream(compressedFileName));
         FileInputStream in = new FileInputStream(uncompressedFileName)) {
      byte[] buf = new byte[1024];
      for (int len; (len = in.read(buf)) > 0; ) {
        out.write(buf, 0, len);
      }

View on GitHub (pinned to 1b7edd19c4)