diff --git a/classpath/java/io/FileInputStream.java b/classpath/java/io/FileInputStream.java index 1c7a6c9532..4c0d576368 100644 --- a/classpath/java/io/FileInputStream.java +++ b/classpath/java/io/FileInputStream.java @@ -55,7 +55,9 @@ public class FileInputStream extends InputStream { } public void close() throws IOException { - close(fd); - fd = -1; + if (fd != -1) { + close(fd); + fd = -1; + } } } diff --git a/classpath/java/io/FileOutputStream.java b/classpath/java/io/FileOutputStream.java index 4d50412414..d61d44e136 100644 --- a/classpath/java/io/FileOutputStream.java +++ b/classpath/java/io/FileOutputStream.java @@ -55,7 +55,9 @@ public class FileOutputStream extends OutputStream { } public void close() throws IOException { - close(fd); - fd = -1; + if (fd != -1) { + close(fd); + fd = -1; + } } }