Index: modules/luni/src/test/java/tests/api/java/io/FileOutputStreamTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/FileOutputStreamTest.java (revision 542579) +++ modules/luni/src/test/java/tests/api/java/io/FileOutputStreamTest.java (working copy) @@ -68,7 +68,10 @@ // Test for method java.io.FileOutputStream(java.lang.String) f = new File(fileName = System.getProperty("user.home"), "fos.tst"); fileName = f.getAbsolutePath(); - fos = new java.io.FileOutputStream(f); + fos = new FileOutputStream(fileName); + + // Regression test for HARMONY-4012 + new FileOutputStream("nul"); } /** Index: modules/portlib/src/main/native/port/windows/hyfile.c =================================================================== --- modules/portlib/src/main/native/port/windows/hyfile.c (revision 542579) +++ modules/portlib/src/main/native/port/windows/hyfile.c (working copy) @@ -504,7 +504,7 @@ return -1; } - if ((flags & HyOpenTruncate) == HyOpenTruncate) + if ((GetFileType(aHandle) == FILE_TYPE_DISK) && ((flags & HyOpenTruncate) == HyOpenTruncate)) { if (0 == CloseHandle (aHandle)) {