skylot/jadx · error · IOException
Failed to save temp file
Error message
Failed to save temp file
What it means
Thrown by CommonFileUtils.saveToTempFile when writing the input stream (and optional data prefix) to a newly created temp file fails. The method first creates a temp file via Files.createTempFile, then wraps any exception during the write (OutputStream operations or copyStream) in an IOException with this message. The original exception is preserved as the cause.
Source
Thrown at jadx-core/src/main/java/jadx/api/plugins/utils/CommonFileUtils.java:42
return new File(".").getCanonicalFile();
} catch (IOException e) {
throw new RuntimeException("Failed to init current working dir constant", e);
}
}
public static Path saveToTempFile(InputStream in, String suffix) throws IOException {
return saveToTempFile(null, in, suffix);
}
public static Path saveToTempFile(byte[] dataPrefix, InputStream in, String suffix) throws IOException {
Path tempFile = Files.createTempFile("jadx-temp-", suffix);
try (OutputStream out = Files.newOutputStream(tempFile)) {
if (dataPrefix != null) {
out.write(dataPrefix);
}
copyStream(in, out);
} catch (Exception e) {
throw new IOException("Failed to save temp file", e);
}
return tempFile;
}
public static boolean safeDeleteFile(File file) {
try {
return file.delete();
} catch (Exception e) {
LOG.warn("Failed to delete file: {}", file, e);
return false;
}
}
public static byte[] loadBytes(InputStream input) throws IOException {
return loadBytes(null, input);
}
public static byte[] loadBytes(byte[] dataPrefix, InputStream in) throws IOException {View on GitHub (pinned to e738a26571)
Solutions
- Check available disk space in the system temp directory (java.io.tmpdir).
- Set -Djava.io.tmpdir to a directory with sufficient space and write permissions.
- Verify the InputStream is open and readable before calling saveToTempFile; for zip entries, check the entry is valid.
- Inspect getCause() on the IOException to distinguish disk I/O errors from stream-reading errors.
Defensive patterns
Strategy: try-catch
Validate before calling
// Check temp directory is writable and has space before calling saveToTempFile
Path tmpDir = Path.of(System.getProperty("java.io.tmpdir"));
FileStore store = Files.getFileStore(tmpDir);
if (store.getUsableSpace() < estimatedSize) {
throw new IOException("Insufficient temp space in " + tmpDir);
} Try / catch
Path tempFile;
try {
tempFile = CommonFileUtils.saveToTempFile(inputStream, ".tmp");
} catch (IOException e) {
LOG.error("Failed to save temp file: {}", e.getCause().getMessage());
throw e;
} Prevention
- Set -Djava.io.tmpdir to a directory with sufficient free disk space for large APK processing.
- Verify the InputStream is open and readable before passing it to saveToTempFile.
- Inspect getCause() to distinguish disk-full/permission errors from input-stream read errors.
When it happens
Trigger: The temp file is created but writing fails due to disk full, permission revoked on the temp directory, the input stream throwing during read, or the output stream being closed unexpectedly. The catch covers out.write(dataPrefix), copyStream(in, out), and the try-with-resources close. Note that Files.createTempFile failures (before the try) are NOT wrapped by this message — they propagate directly.
Common situations: Temp directory (/tmp or java.io.tmpdir) is full or read-only. The InputStream provided is already closed or reads from a corrupted zip entry. Running jadx in a container with limited writable storage. Large APK inputs that exhaust disk space during temp file writing.
Related errors
- Failed to save mapping json
- Resource file save error
- Failed to write metadata file
- Failed to reset code cache
- Failed to remove code cache for {}
AI-assisted analysis of skylot/jadx@e738a26571 (2026-08-14).
Data as JSON: /api/errors/ef58fb24e7f48b30.
Report an issue: GitHub.