JDK-8358214 : Release Note: File operations with directory or file names ending in a space now consistently fail on Windows
  • Type: Sub-task
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 25
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: windows
  • Submitted: 2025-05-30
  • Updated: 2025-06-01
Description
Prior to JDK 25, a `java.io.File` could be created on Windows from an abstract pathname with a trailing space such as in "C:\\SomeFolder\\SomeFile ", or an abstract pathname containing a name with a trailing space in its name sequence such as in "C:\\Users\\foo\\bar \\gus". Such names are not legal on Windows. Beginning with JDK 25, `File`s created with such an abstract pathname are considered invalid. Attempting to create a file or a directory from such an invalid `File` will fail and might result in an exception being thrown.

==

File operations on a path with a trailing space in a directory or file name, e.g. "C:\\SomeFolder\\SomeFile ", now fail consistently on Windows. For example. `File::mkdir` return will `false, or `File::createNewFile` will throw `IOException` if an element in the path has a trailing space.