Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Java IO have a maximum file name length limit?

Different operating systems have different file name max lengths. Does Java have any limit on file name length when working with files?

like image 836
Dónal Boyle Avatar asked Dec 22 '10 19:12

Dónal Boyle


People also ask

Is there a maximum file name length?

The maximum length of a pathname is 256 characters, which includes all parent directories and the filename. 255-character mixed-case long filename is possible only for files, or folders with no sub-folders, at the root folder of any drive.

What is the longest file name allowed in Windows 10?

In Windows 10, you can enable long file name support, which allows file names up to 32,767 characters (although you lose a few characters for mandatory characters that are part of the name).

What is the maximum length of the filename in due?

Explanation: The maximum length of the filename is 8 characters in the DOS operating system. It is commonly known as an 8.3 filename.

What is the maximum number of characters that can be used to name a file or directory in Linux?

Linux has a maximum filename length of 255 characters for most filesystems (including EXT4), and a maximum path of 4096 characters.


2 Answers

Java has no maximum file name length, except obviously for the String max length limit (which is the array max length, i.e. Integer.MAX_VALUE). Maybe some JVMs have a lower limit but I never run into such a problem (and I'm almost certain it would be a bug with respect to Java specifications), certainly OSes can have one.

like image 124
Guillaume Avatar answered Oct 11 '22 16:10

Guillaume


Windows has a 256 character filename length. Unix has about the same I believe. So while the Java IO may not have a defined length (String length maybe for sure), it would be dependent on the implementation for the operating system.

like image 25
Casey Avatar answered Oct 11 '22 18:10

Casey